1
1
import uuid
2
- from django .db import models
2
+ from math import floor
3
+
3
4
from django .contrib .auth import get_user_model
4
- from django .utils . text import slugify
5
+ from django .db import models
5
6
from django .utils import timezone
6
- from math import floor
7
- from projects .models import Category
7
+ from django .utils .text import slugify
8
8
9
9
Creator = get_user_model ()
10
10
@@ -17,16 +17,14 @@ def __str__(self):
17
17
try :
18
18
image = self .file_url
19
19
except AttributeError :
20
- image = ''
20
+ image = ""
21
21
return "Photo <%s:%s>" % (self .public_id , image )
22
22
23
23
24
24
class InspiringArtist (models .Model ):
25
- '''this should be having more fields to distinguish an artist '''
26
- image = models .ForeignKey (Image ,
27
- on_delete = models .CASCADE ,
28
- null = True ,
29
- blank = True )
25
+ """this should be having more fields to distinguish an artist"""
26
+
27
+ image = models .ForeignKey (Image , on_delete = models .CASCADE , null = True , blank = True )
30
28
short_biography = models .TextField (max_length = 10000 , blank = True , null = True )
31
29
name = models .CharField (max_length = 100 , null = True )
32
30
@@ -35,41 +33,43 @@ def __str__(self):
35
33
36
34
37
35
class Activity (models .Model ):
38
- id = models .UUIDField (primary_key = True ,
39
- default = uuid .uuid4 ,
40
- editable = False ,
41
- unique = True )
42
- creators = models .ManyToManyField (Creator ,
43
- related_name = "activities_created" )
36
+ id = models .UUIDField (
37
+ primary_key = True , default = uuid .uuid4 , editable = False , unique = True
38
+ )
39
+ creators = models .ManyToManyField (Creator , related_name = "activities_created" )
44
40
title = models .CharField (max_length = 500 )
45
- category = models .ManyToManyField ("projects.Category" ,blank = True , related_name = "activities" )
46
- introduction = models .CharField (max_length = 10000 ,blank = True )
41
+ category = models .ManyToManyField (
42
+ "projects.Category" , blank = True , related_name = "activities"
43
+ )
44
+ introduction = models .CharField (max_length = 10000 , blank = True )
47
45
class_grade = models .CharField (max_length = 50 , blank = True )
48
-
46
+
49
47
learning_goals = models .TextField (max_length = 10000 , blank = True , null = True )
50
48
facilitation_tips = models .TextField (max_length = 10000 , blank = True , null = True )
51
49
motivation = models .TextField (max_length = 10000 , blank = True , null = True )
52
50
video = models .URLField (max_length = 1000 , blank = True , null = True )
53
51
materials_used = models .TextField (max_length = 5000 , blank = True , null = True )
54
- materials_used_image = models .ForeignKey (Image ,
55
- on_delete = models .SET_NULL ,
56
- null = True ,
57
- blank = True ,
58
- )
59
- inspiring_artist = models .ForeignKey (InspiringArtist ,
60
- on_delete = models .SET_NULL ,
61
- null = True ,
62
- related_name = "inspiring_artist_activities" ,
63
- blank = True ,
64
- )
65
- views = models .ManyToManyField (Creator ,
66
- blank = True ,
67
- related_name = "activities_viewed" )
52
+ materials_used_image = models .ForeignKey (
53
+ Image ,
54
+ on_delete = models .SET_NULL ,
55
+ null = True ,
56
+ blank = True ,
57
+ )
58
+ inspiring_artist = models .ForeignKey (
59
+ InspiringArtist ,
60
+ on_delete = models .SET_NULL ,
61
+ null = True ,
62
+ related_name = "inspiring_artist_activities" ,
63
+ blank = True ,
64
+ )
65
+ views = models .ManyToManyField (
66
+ Creator , blank = True , related_name = "activities_viewed"
67
+ )
68
68
views_count = models .IntegerField (blank = True , default = 0 )
69
69
saved_count = models .IntegerField (blank = True , default = 0 )
70
- saved_by = models .ManyToManyField (Creator ,
71
- blank = True ,
72
- related_name = "activities_saved" )
70
+ saved_by = models .ManyToManyField (
71
+ Creator , blank = True , related_name = "activities_saved"
72
+ )
73
73
created_on = models .DateTimeField (default = timezone .now , null = True )
74
74
publish = models .BooleanField (default = False , null = True )
75
75
slug = models .SlugField (unique = True , max_length = 1000 )
@@ -79,56 +79,59 @@ def save(self, *args, **kwargs):
79
79
pass
80
80
else :
81
81
uid = str (uuid .uuid4 ())
82
- uid = uid [0 : floor (len (uid ) / 6 )]
82
+ uid = uid [0 : floor (len (uid ) / 6 )]
83
83
self .slug = slugify (self .title ) + "-" + uid
84
84
85
85
super ().save (* args , ** kwargs )
86
86
87
87
def __str__ (self ):
88
88
return self .title
89
89
90
+ class Meta :
91
+ verbose_name_plural = "Activities"
92
+
90
93
91
94
class InspiringExample (models .Model ):
92
- activity = models .ForeignKey (Activity ,
93
- on_delete = models .CASCADE ,
94
- null = True ,
95
- related_name = "inspiring_examples" ,
96
- blank = True )
95
+ activity = models .ForeignKey (
96
+ Activity ,
97
+ on_delete = models .CASCADE ,
98
+ null = True ,
99
+ related_name = "inspiring_examples" ,
100
+ blank = True ,
101
+ )
97
102
description = models .TextField (max_length = 10000 , blank = True )
98
103
credit = models .TextField (max_length = 1000 , blank = True )
99
- image = models .ForeignKey (Image ,
100
- on_delete = models .CASCADE ,
101
- null = True ,
102
- blank = True )
104
+ image = models .ForeignKey (Image , on_delete = models .CASCADE , null = True , blank = True )
103
105
104
106
def __str__ (self ):
105
107
return self .image
106
108
107
109
108
110
class ActivityImage (models .Model ):
109
- activity = models .ForeignKey (Activity ,
110
- on_delete = models .CASCADE ,
111
- null = True ,
112
- related_name = "activity_images" ,
113
- blank = True )
114
- image = models .ForeignKey (Image ,
115
- on_delete = models .CASCADE ,
116
- null = True ,
117
- blank = True )
111
+ activity = models .ForeignKey (
112
+ Activity ,
113
+ on_delete = models .CASCADE ,
114
+ null = True ,
115
+ related_name = "activity_images" ,
116
+ blank = True ,
117
+ )
118
+ image = models .ForeignKey (Image , on_delete = models .CASCADE , null = True , blank = True )
118
119
119
120
def __str__ (self ):
120
121
return self .image
121
122
122
123
123
124
class ActivityMakingStep (models .Model ):
124
- activity = models .ForeignKey (Activity ,
125
- on_delete = models .CASCADE ,
126
- null = True ,
127
- related_name = "making_steps" ,
128
- blank = True )
129
-
130
- title = models .TextField (max_length = 500 ,null = True )
131
- image = models .ManyToManyField (Image ,blank = True )
125
+ activity = models .ForeignKey (
126
+ Activity ,
127
+ on_delete = models .CASCADE ,
128
+ null = True ,
129
+ related_name = "making_steps" ,
130
+ blank = True ,
131
+ )
132
+
133
+ title = models .TextField (max_length = 500 , null = True )
134
+ image = models .ManyToManyField (Image , blank = True )
132
135
description = models .TextField (max_length = 10000 , blank = True )
133
136
step_order = models .IntegerField ()
134
137
0 commit comments