Browse Source

added the "not nullable" name on models

/\/ \-/ ❭❬ 1 year ago
parent
commit
c2fcae7ecd

+ 3
- 3
app/models/blog.py View File

@@ -9,7 +9,7 @@ class BlogPost(db.Model):
9 9
     __tablename__ = 'blog_posts'
10 10
 
11 11
     id = db.Column(db.Integer, primary_key=True)
12
-    name = db.Column(db.String(256))
12
+    name = db.Column(db.String(256), nullable=False)
13 13
     description = db.Column(db.Text)
14 14
     # Date of creation
15 15
     timestamp = db.Column(db.DateTime, default=datetime.utcnow)
@@ -17,14 +17,14 @@ class BlogPost(db.Model):
17 17
     collectives = db.relationship(
18 18
         'Collective',
19 19
         secondary='blog_posts_collectives',
20
-        cascade='all',
20
+        #cascade='all',
21 21
         single_parent='True',
22 22
         lazy='select',
23 23
         back_populates='blog_posts')
24 24
     contributors = db.relationship(
25 25
         'Contributor',
26 26
         secondary='blog_posts_contributors',
27
-        cascade='all',
27
+        #cascade='all',
28 28
         single_parent='True',
29 29
         lazy='select',
30 30
         back_populates='blog_posts')

+ 3
- 3
app/models/channel.py View File

@@ -6,19 +6,19 @@ class Channel(db.Model):
6 6
     __tablename__ = "channels"
7 7
 
8 8
     id = db.Column(db.Integer, primary_key=True)
9
-    name = db.Column(db.String(128))
9
+    name = db.Column(db.String(128), nullable=False)
10 10
     description = db.Column(db.Text)
11 11
     collectives = db.relationship(
12 12
         'Collective',
13 13
         secondary='channels_collectives',
14
-        cascade='all',
14
+        #cascade='all',
15 15
         single_parent='True',
16 16
         lazy='select',
17 17
         back_populates='channels')
18 18
     contributors = db.relationship(
19 19
         'Contributor',
20 20
         secondary='channels_contributors',
21
-        cascade='all',
21
+        #cascade='all',
22 22
         single_parent='True',
23 23
         lazy='select',
24 24
         back_populates='channels')

+ 6
- 6
app/models/collective.py View File

@@ -8,7 +8,7 @@ from .relationships import *
8 8
 class Collective(db.Model):
9 9
     __tablename__ = 'collectives'
10 10
     id = db.Column(db.Integer, primary_key=True)
11
-    name = db.Column(db.String(128))
11
+    name = db.Column(db.String(128), nullable=False)
12 12
     description = db.Column(db.Text)
13 13
     email = db.Column(db.String(256))
14 14
     website = db.Column(db.String(256))
@@ -16,35 +16,35 @@ class Collective(db.Model):
16 16
     channels = db.relationship(
17 17
         'Channel',
18 18
         secondary='channels_collectives',
19
-        cascade='all',
19
+        #cascade='all',
20 20
         single_parent='True',
21 21
         lazy='select',
22 22
         back_populates='collectives')
23 23
     contributors = db.relationship(
24 24
         'Contributor',
25 25
         secondary = 'collectives_contributors',
26
-        cascade='all',
26
+        #cascade='all',
27 27
         single_parent='True',
28 28
         lazy = 'select',
29 29
         back_populates = 'collectives')
30 30
     podcasts = db.relationship(
31 31
         'Podcast',
32 32
         secondary='podcasts_collectives',
33
-        cascade='all',
33
+        #cascade='all',
34 34
         single_parent='True',
35 35
         lazy='select',
36 36
         back_populates='collectives')
37 37
     sections = db.relationship(
38 38
         'Section',
39 39
         secondary='sections_collectives',
40
-        cascade='all',
40
+        #cascade='all',
41 41
         single_parent='True',
42 42
         lazy='select',
43 43
         back_populates='collectives')
44 44
     blog_posts = db.relationship(
45 45
         'BlogPost',
46 46
         secondary='blog_posts_collectives',
47
-        cascade='all',
47
+        #cascade='all',
48 48
         single_parent='True',
49 49
         lazy='select',
50 50
         back_populates='collectives')

+ 6
- 6
app/models/contributor.py View File

@@ -5,7 +5,7 @@ from .relationships import *
5 5
 class Contributor(db.Model):
6 6
     __tablename__ = 'contributors'
7 7
     id = db.Column(db.Integer, primary_key=True)
8
-    name = db.Column(db.String(128))
8
+    name = db.Column(db.String(128), nullable=False)
9 9
     status = db.Column(db.String(128))
10 10
     description = db.Column(db.Text)
11 11
     email = db.Column(db.String(256))
@@ -14,35 +14,35 @@ class Contributor(db.Model):
14 14
     channels = db.relationship(
15 15
         'Channel',
16 16
         secondary='channels_contributors',
17
-        cascade='all',
17
+        #cascade='all',
18 18
         single_parent='True',
19 19
         lazy='select',
20 20
         back_populates='contributors')
21 21
     collectives = db.relationship(
22 22
         'Collective',
23 23
         secondary='collectives_contributors',
24
-        cascade='all',
24
+        #cascade='all',
25 25
         single_parent='True',
26 26
         lazy='select',
27 27
         back_populates='contributors')
28 28
     podcasts = db.relationship(
29 29
         'Podcast',
30 30
         secondary='podcasts_contributors',
31
-        cascade='all',
31
+        #cascade='all',
32 32
         single_parent='True',
33 33
         lazy='select',
34 34
         back_populates='contributors')
35 35
     sections = db.relationship(
36 36
         'Section',
37 37
         secondary='sections_contributors',
38
-        cascade='all',
38
+        #cascade='all',
39 39
         single_parent='True',
40 40
         lazy='select',
41 41
         back_populates='contributors')
42 42
     blog_posts = db.relationship(
43 43
         'BlogPost',
44 44
         secondary='blog_posts_contributors',
45
-        cascade='all',
45
+        #cascade='all',
46 46
         single_parent='True',
47 47
         lazy='select',
48 48
         back_populates='contributors')

+ 1
- 1
app/models/event.py View File

@@ -12,7 +12,7 @@ class Event(db.Model):
12 12
     __tablename__ = 'events'
13 13
 
14 14
     id = db.Column(db.Integer, primary_key=True)
15
-    name = db.Column(db.String(256))
15
+    name = db.Column(db.String(256), nullable=False)
16 16
     description = db.Column(db.Text)
17 17
     # Where the event will take place
18 18
     place = db.Column(db.String(128))

+ 1
- 1
app/models/page.py View File

@@ -4,7 +4,7 @@ class Page(db.Model):
4 4
     """ Pages """
5 5
     __tablename__ = 'pages'
6 6
     id = db.Column(db.Integer, primary_key=True)
7
-    name = db.Column(db.String(256))
7
+    name = db.Column(db.String(256), nullable=False)
8 8
     description = db.Column(db.Text)
9 9
     channel_id = db.Column(db.Integer, db.ForeignKey('channels.id'))
10 10
 

+ 3
- 3
app/models/podcast.py View File

@@ -10,7 +10,7 @@ class Podcast(db.Model):
10 10
     __tablename__ = 'podcasts'
11 11
 
12 12
     id = db.Column(db.Integer, primary_key=True)
13
-    name = db.Column(db.String(256))
13
+    name = db.Column(db.String(256), nullable=False)
14 14
     description = db.Column(db.Text)
15 15
     # Date of recording
16 16
     date = db.Column(db.Date, default=datetime.utcnow)
@@ -22,14 +22,14 @@ class Podcast(db.Model):
22 22
     collectives = db.relationship(
23 23
         'Collective',
24 24
         secondary='podcasts_collectives',
25
-        cascade='all',
25
+        #cascade='all',
26 26
         single_parent='True',
27 27
         lazy='select',
28 28
         back_populates='podcasts')
29 29
     contributors = db.relationship(
30 30
         'Contributor',
31 31
         secondary='podcasts_contributors',
32
-        cascade='all',
32
+        #cascade='all',
33 33
         single_parent='True',
34 34
         lazy='select',
35 35
         back_populates='podcasts')

+ 3
- 3
app/models/section.py View File

@@ -10,7 +10,7 @@ class Section(db.Model):
10 10
     __tablename__ = "sections"
11 11
 
12 12
     id = db.Column(db.Integer, primary_key=True)
13
-    name = db.Column(db.String(256), default="Nom de la section")
13
+    name = db.Column(db.String(256), default="Nom de la section", nullable=False)
14 14
     description = db.Column(db.Text)
15 15
     # Date of publication
16 16
     timestamp = db.Column(db.DateTime, default=datetime.utcnow)
@@ -24,14 +24,14 @@ class Section(db.Model):
24 24
     collectives = db.relationship(
25 25
         'Collective',
26 26
         secondary = 'sections_collectives',
27
-        cascade='all',
27
+        #cascade='all',
28 28
         single_parent='True',
29 29
         lazy = 'select',
30 30
         back_populates = 'sections')
31 31
     contributors = db.relationship(
32 32
         'Contributor',
33 33
         secondary = 'sections_contributors',
34
-        cascade='all',
34
+        #cascade='all',
35 35
         single_parent='True',
36 36
         lazy = 'select',
37 37
         back_populates = 'sections')

+ 1
- 2
app/models/tag.py View File

@@ -5,12 +5,11 @@ class Tag(db.Model):
5 5
     __tablename__ = "tags"
6 6
 
7 7
     id = db.Column(db.Integer, primary_key=True)
8
-    name = db.Column(db.String(128), default="Nom du tag")
8
+    name = db.Column(db.String(128), default="Nom du tag", nullable=False)
9 9
     channel_id = db.Column(db.Integer, db.ForeignKey('channels.id'))
10 10
     collective_id = db.Column(db.Integer, db.ForeignKey('collectives.id'))
11 11
     podcast_id = db.Column(db.Integer, db.ForeignKey('podcasts.id'))
12 12
     section_id = db.Column(db.Integer, db.ForeignKey('sections.id'))
13
-    #FIXME ADD COLLECTIVE
14 13
 
15 14
     def __repr__(self):
16 15
         return '<TAG %r>' % self.name

Loading…
Cancel
Save