forked from Shreyas8905/EventZone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
43 lines (33 loc) · 1.37 KB
/
models.py
File metadata and controls
43 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
email = db.Column(db.String(100), unique=True, nullable=False)
password = db.Column(db.String(100), nullable=False)
phone_number = db.Column(db.String(15), nullable=False)
@property
def is_active(self):
"""All users are active by default. Adjust logic as needed."""
return True
@property
def is_authenticated(self):
"""Return True if the user is authenticated."""
return True
@property
def is_anonymous(self):
"""Return False as this user is not anonymous."""
return False
def get_id(self):
"""Return the user's unique identifier as a string."""
return str(self.id)
class Event(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100), nullable=False)
place = db.Column(db.String(100), nullable=False)
date = db.Column(db.Date, nullable=False)
time = db.Column(db.Time, nullable=False)
organizer_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
class Participated(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
event_id = db.Column(db.Integer, db.ForeignKey('event.id'), primary_key=True)