384 lines
12 KiB
Python
384 lines
12 KiB
Python
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, Text, text
|
|
from sqlalchemy.sql import func
|
|
|
|
from database import Base
|
|
|
|
|
|
class Users(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
social_id = Column(Text)
|
|
type = Column(Integer)
|
|
full_name = Column(String(255), index=True, unique=True)
|
|
email = Column(String(255), index=True, unique=True)
|
|
password = Column(String(255))
|
|
gender = Column(Integer)
|
|
mobile = Column(String(255))
|
|
user_image = Column(String(255))
|
|
city_id = Column(Integer, ForeignKey("cities.id"))
|
|
user_type = Column(Integer)
|
|
otp = Column(String(255))
|
|
otp_valid_time = Column(DateTime)
|
|
access_key = Column(Text)
|
|
lang_type = Column(Integer)
|
|
badge = Column(Integer)
|
|
status = Column(Integer, server_default=text("0"))
|
|
admin_status = Column(Integer, server_default=text("0"))
|
|
device_id = Column(Text)
|
|
device_type = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
|
|
def __init__(
|
|
self,
|
|
full_name,
|
|
email,
|
|
password,
|
|
gender,
|
|
mobile,
|
|
city_id,
|
|
user_type,
|
|
lang_type,
|
|
badge,
|
|
device_id,
|
|
device_type,
|
|
social_id="",
|
|
access_key="",
|
|
user_image=None,
|
|
type=0,
|
|
):
|
|
self.social_id = social_id
|
|
self.type = type
|
|
self.full_name = full_name
|
|
self.email = email
|
|
self.password = password
|
|
self.gender = gender
|
|
self.mobile = mobile
|
|
self.user_image = user_image
|
|
self.city_id = city_id
|
|
self.user_type = user_type
|
|
self.access_key = access_key
|
|
self.lang_type = lang_type
|
|
self.badge = badge
|
|
self.device_id = device_id
|
|
self.device_type = device_type
|
|
|
|
|
|
class Cities(Base):
|
|
__tablename__ = "cities"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(255))
|
|
image = Column(String(255))
|
|
status = Column(Enum("1", "0"))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(self, name, image, status):
|
|
self.name = name
|
|
self.image = image
|
|
self.status = status
|
|
|
|
|
|
class Games(Base):
|
|
__tablename__ = "games"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(255))
|
|
image = Column(String(255))
|
|
date_time = Column(DateTime)
|
|
price = Column(String(100))
|
|
description = Column(Text)
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
gender = Column(Enum("1", "2", "3"))
|
|
city_id = Column(Integer, ForeignKey("cities.id"))
|
|
venue_id = Column(Integer, ForeignKey("venues.id"))
|
|
sports_id = Column(Integer, ForeignKey("sports.id"))
|
|
no_of_player = Column(Integer)
|
|
min_player = Column(Integer)
|
|
already_player = Column(Integer)
|
|
no_of_already_player = Column(Integer)
|
|
payment_mode = Column(Integer)
|
|
card_id = Column(Integer)
|
|
status = Column(Integer, server_default=text("1"))
|
|
game_status = Column(Integer, server_default=text("0"))
|
|
cancel_status = Column(Integer)
|
|
cancel_date = Column(DateTime)
|
|
noti_status = Column(Integer, server_default=text("0"))
|
|
conduct_status = Column(Integer, server_default=text("1"))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self,
|
|
name,
|
|
image,
|
|
date_time,
|
|
price,
|
|
description,
|
|
user_id,
|
|
gender,
|
|
city_id,
|
|
venue_id,
|
|
sports_id,
|
|
no_of_player,
|
|
min_player,
|
|
already_player,
|
|
no_of_already_player,
|
|
payment_mode,
|
|
card_id,
|
|
):
|
|
self.name = name
|
|
self.image = image
|
|
self.date_time = date_time
|
|
self.price = price
|
|
self.description = description
|
|
self.user_id = user_id
|
|
self.gender = gender
|
|
self.city_id = city_id
|
|
self.venue_id = venue_id
|
|
self.sports_id = sports_id
|
|
self.no_of_player = no_of_player
|
|
self.no_of_already_player = no_of_already_player
|
|
self.payment_mode = payment_mode
|
|
self.card_id = card_id
|
|
|
|
|
|
class Payments(Base):
|
|
__tablename__ = "payments"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
game_id = Column(Integer, ForeignKey("games.id"))
|
|
amount = Column(Integer)
|
|
token = Column(String(100))
|
|
charge_id = Column(String(200))
|
|
transfer_id = Column(String(200))
|
|
transaction_id = Column(String(200))
|
|
account_no = Column(String(200))
|
|
description = Column(Text)
|
|
pay_mode = Column(Integer)
|
|
status = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self,
|
|
user_id,
|
|
game_id,
|
|
amount,
|
|
token,
|
|
charge_id,
|
|
transfer_id,
|
|
transaction_id,
|
|
account_no,
|
|
description,
|
|
pay_mode,
|
|
status,
|
|
):
|
|
self.user_id = user_id
|
|
self.game_id = game_id
|
|
self.amount = amount
|
|
self.token = token
|
|
self.charge_id = charge_id
|
|
self.transfer_id = transfer_id
|
|
self.transaction_id = transaction_id
|
|
self.account_no = account_no
|
|
self.description = description
|
|
self.pay_mode = pay_mode
|
|
self.status = status
|
|
|
|
|
|
class PlayerAvailabilities(Base):
|
|
__tablename__ = "player_availabilities"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
game_id = Column(Integer, ForeignKey("games.id"))
|
|
player_id = Column(Integer, ForeignKey("users.id"))
|
|
status = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, game_id, player_id, status,
|
|
):
|
|
self.game_id = game_id
|
|
self.player_id = player_id
|
|
self.status = status
|
|
|
|
|
|
class PlayerCancelGames(Base):
|
|
__tablename__ = "player_cancel_games"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
player_id = Column(Integer, ForeignKey("users.id"))
|
|
game_id = Column(Integer, ForeignKey("games.id"))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, player_id, game_id,
|
|
):
|
|
self.player_id = player_id
|
|
self.game_id = game_id
|
|
|
|
|
|
class PurchaseGames(Base):
|
|
__tablename__ = "purchase_games"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
game_id = Column(Integer, ForeignKey("games.id"))
|
|
user_id = Column(Integer, ForeignKey("users.id"))
|
|
pay_mode = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, game_id, user_id, pay_mode,
|
|
):
|
|
self.game_id = game_id
|
|
self.user_id = user_id
|
|
self.pay_mode = pay_mode
|
|
|
|
|
|
class Sports(Base):
|
|
__tablename__ = "sports"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(255))
|
|
spanish_name = Column(String(100))
|
|
status = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, name, spanish_name, status,
|
|
):
|
|
self.name = name
|
|
self.spanish_name = spanish_name
|
|
self.status = status
|
|
|
|
|
|
class Teams(Base):
|
|
__tablename__ = "teams"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("users_id"))
|
|
team_id = Column(Enum("1", "2"))
|
|
game_id = Column(Integer, ForeignKey("games_id"))
|
|
status = Column(Integer)
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, game_id, user_id, team_id, status,
|
|
):
|
|
self.game_id = game_id
|
|
self.user_id = user_id
|
|
self.team_id = team_id
|
|
self.status = status
|
|
|
|
|
|
class UserRatings(Base):
|
|
__tablename__ = "user_ratings"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
game_id = Column(Integer, ForeignKey("games_id"))
|
|
user_id = Column(Integer, ForeignKey("users_id"))
|
|
player_id = Column(Integer, ForeignKey("users_id"))
|
|
rating = Column(String(100))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
user_type = Column(Integer)
|
|
|
|
def __init__(self, game_id, user_id, player_id, rating, user_type):
|
|
self.game_id = game_id
|
|
self.user_id = user_id
|
|
self.player_id = player_id
|
|
self.rating = rating
|
|
self.user_type = user_type
|
|
|
|
|
|
class VenueImages(Base):
|
|
__tablename__ = "venue_images"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
venue_id = Column(Integer, ForeignKey("venues_id"))
|
|
user_id = Column(Integer, ForeignKey("users_id"))
|
|
image = Column(String(255))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, venue_id, user_id, image,
|
|
):
|
|
self.venue_id = venue_id
|
|
self.user_id = user_id
|
|
self.image = image
|
|
|
|
|
|
class Venues(Base):
|
|
__tablename__ = "venues"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
user_id = Column(Integer, ForeignKey("users_id"))
|
|
address = Column(Text)
|
|
latitude = Column(String(100))
|
|
longitude = Column(String(100))
|
|
name = Column(String(100))
|
|
sports_id = Column(Integer, ForeignKey("sports_id"))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, user_id, address, latitude, longitude, name, sports_id,
|
|
):
|
|
self.user_id = user_id
|
|
self.address = address
|
|
self.latitude = latitude
|
|
self.longitude = longitude
|
|
self.name = name
|
|
self.sports_id = sports_id
|
|
|
|
|
|
class ViewNews(Base):
|
|
__tablename__ = "view_news"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
news_id = Column(Integer)
|
|
user_id = Column(Integer, ForeignKey("users_id"))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, news_id, user_id,
|
|
):
|
|
self.news_id = news_id
|
|
self.user_id = user_id
|
|
|
|
|
|
class WebBookings(Base):
|
|
__tablename__ = "web_bookings"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
name = Column(String(255))
|
|
email = Column(String(255))
|
|
contact = Column(String(100))
|
|
message = Column(Text)
|
|
game = Column(String(255))
|
|
city = Column(String(100))
|
|
created = Column(DateTime, nullable=False, server_default=func.now())
|
|
updated = Column(DateTime, nullable=True, onupdate=func.now())
|
|
|
|
def __init__(
|
|
self, user_id, address, name, email, contact, message, game, city,
|
|
):
|
|
self.user_id = user_id
|
|
self.address = address
|
|
self.name = name
|
|
self.email = email
|
|
self.contact = contact
|
|
self.message = message
|
|
self.game = game
|
|
self.city = city
|