odapi/database/models.py

385 lines
11 KiB
Python
Raw Normal View History

2020-07-03 02:03:02 +02:00
from database import Base
from sqlalchemy import Column, Integer, String, DateTime, Text, Enum, text
from sqlalchemy.sql import func
class Users(Base):
2020-07-03 02:03:02 +02:00
__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)
user_type = Column(Integer)
otp = Column(String(255))
otp_valid_time = Column(DateTime)
access_key = Column(Text)
lang_type = Column(Integer)
badge = Column(Integer)
2020-07-03 02:03:02 +02:00
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):
2020-07-03 02:03:02 +02:00
__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())
modified = Column(DateTime, nullable=False, onupdate=func.now())
def __init__(self, name, image, status, created, modified):
self.name = name
self.image = image
self.status = status
self.created = created
self.modified = modified
class Games(Base):
2020-07-03 02:03:02 +02:00
__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)
gender = Column(Enum("1", "2", "3"))
city_id = Column(Integer)
venue_id = Column(Integer)
sports_id = Column(Integer)
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)
2020-07-03 02:03:02 +02:00
status = Column(Integer, server_default=text("1"))
game_status = Column(Integer, server_default=text("0"))
cancel_status = Column(Integer)
cancel_date = Column(DateTime)
2020-07-03 02:03:02 +02:00
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())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "payments"
id = Column(Integer, primary_key=True, autoincrement=True)
user_id = Column(Integer)
game_id = Column(Integer)
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())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "player_availabilities"
id = Column(Integer, primary_key=True, autoincrement=True)
game_id = Column(Integer)
player_id = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "player_cancel_games"
id = Column(Integer, primary_key=True, autoincrement=True)
player_id = Column(Integer)
game_id = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, onupdate=func.now())
def __init__(
self, player_id, game_id,
):
self.player_id = player_id
self.game_id = game_id
class PurchaseGames(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "purchase_games"
id = Column(Integer, primary_key=True, autoincrement=True)
game_id = Column(Integer)
user_id = Column(Integer)
pay_mode = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__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())
modified = Column(DateTime, nullable=False, onupdate=func.now())
def __init__(
self, name, spanish_name, status,
):
self.name = name
self.spanish_name = spanish_name
self.status = status
class Teams(Base):
2020-07-03 02:03:02 +02:00
__tablename__ = "teams"
id = Column(Integer, primary_key=True, autoincrement=True)
user_id = Column(Integer)
team_id = Column(Enum("1", "2"))
game_id = Column(Integer)
status = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "user_ratings"
id = Column(Integer, primary_key=True, autoincrement=True)
game_id = Column(Integer)
user_id = Column(Integer)
player_id = Column(Integer)
rating = Column(String(100))
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "venue_images"
id = Column(Integer, primary_key=True, autoincrement=True)
venue_id = Column(Integer)
user_id = Column(Integer)
image = Column(String(255))
created = Column(DateTime, nullable=False, server_default=func.now())
updated = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "venues"
id = Column(Integer, primary_key=True, autoincrement=True)
user_id = Column(Integer)
address = Column(Text)
latitude = Column(String(100))
longitude = Column(String(100))
name = Column(String(100))
sports_id = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
modified = Column(DateTime, nullable=False, 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):
2020-07-03 02:03:02 +02:00
__tablename__ = "view_news"
id = Column(Integer, primary_key=True, autoincrement=True)
news_id = Column(Integer)
user_id = Column(Integer)
created = Column(DateTime, nullable=False, server_default=func.now())
updated = Column(DateTime, nullable=False, onupdate=func.now())
def __init__(
self, news_id, user_id,
):
self.news_id = news_id
self.user_id = user_id
class WebBookings(Base):
2020-07-03 02:03:02 +02:00
__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=False, 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