-
Notifications
You must be signed in to change notification settings - Fork 1
/
python_pep8_model.txt
204 lines (177 loc) · 8.42 KB
/
python_pep8_model.txt
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
Check results
=============
E501:12:80:line too long (101 > 79 characters)
E501:14:80:line too long (90 > 79 characters)
E501:20:80:line too long (102 > 79 characters)
E501:22:80:line too long (91 > 79 characters)
E501:28:80:line too long (105 > 79 characters)
E501:30:80:line too long (94 > 79 characters)
E501:95:80:line too long (87 > 79 characters)
E501:96:80:line too long (91 > 79 characters)
E501:98:80:line too long (82 > 79 characters)
E501:99:80:line too long (85 > 79 characters)
E501:100:80:line too long (94 > 79 characters)
E501:124:80:line too long (86 > 79 characters)
E501:130:80:line too long (103 > 79 characters)
E501:133:80:line too long (91 > 79 characters)
E501:134:80:line too long (98 > 79 characters)
E501:135:80:line too long (92 > 79 characters)
E501:149:80:line too long (84 > 79 characters)
E501:150:80:line too long (80 > 79 characters)
E501:154:80:line too long (80 > 79 characters)
E501:157:80:line too long (103 > 79 characters)
E501:162:80:line too long (87 > 79 characters)
E501:163:80:line too long (86 > 79 characters)
E501:169:80:line too long (87 > 79 characters)
E501:170:80:line too long (91 > 79 characters)
E501:173:80:line too long (103 > 79 characters)
Code
=============
from django.db import models
from rest_framework import serializers
from django.contrib.auth import get_user_model
from ucd_project_4 import settings
# Referencing the standard Django User model
# => Aim of object/model :
# Capture details of connected user for login/signup function
User = get_user_model()
# Climate object/model to connect to Items (via ManyToMany relation) / Bags (via ForeignKey relation)
# => Aim of object/model :
# Capture details of possible climates to associate to the road where the bag will be used
class Climate(models.Model):
name = models.CharField(blank=True, null=True, max_length=100)
pass
# Landform object/model to connect to Items (via ManyToMany relation) / Bags (via ForeignKey relation)
# => Aim of object/model :
# Capture details of possible landforms to associate to the road where the bag will be used
class Landform(models.Model):
name = models.CharField(blank=True, null=True, max_length=100)
pass
# Environment object/model to connect to Items (via ManyToMany relation) / Bags (via ForeignKey relation)
# => Aim of object/model :
# Capture details of possible environments to associate to the road where the bag will be used
class Environment(models.Model):
name = models.CharField(blank=True, null=True, max_length=100)
pass
# Serialize climates for Item object (via ManyToMany relation)
class ClimateSerializer(serializers.ModelSerializer):
class Meta:
model = Climate
fields = '__all__'
depth = 1
# Serialize landforms for Item object (via ManyToMany relation)
class LandformSerializer(serializers.ModelSerializer):
class Meta:
model = Landform
fields = '__all__'
depth = 1
# Serialize environments for Item object (via ManyToMany relation)
class EnvironmentSerializer(serializers.ModelSerializer):
class Meta:
model = Environment
fields = '__all__'
depth = 1
# Item object/model to connect to Bags (via ManyToMany relation)
# => Aim of object/model :
# Capture details of physical objects to be packed in the bag
# => Models/objects connected to Item model/object via ManyToMany relation :
# Climate, Landform, Environment
class Item(models.Model):
Clothes = 'Clothes'
Linens = 'Linens'
Communication = 'Communication'
Safety = 'Safety'
Cooking = 'Cooking'
Food_Drink = 'Food_Drink'
Hygiene = 'Hygiene'
Health = 'Health'
Lightning = 'Lightning'
Orientation = 'Orientation'
Tools = 'Tools'
Weapons = 'Weapons'
CATEGORIES = [
(Clothes, 'Clothes'),
(Linens, 'Linens'),
(Communication, 'Communication'),
(Safety, 'Safety'),
(Cooking, 'Cooking'),
(Food_Drink, 'Food_Drink'),
(Hygiene, 'Hygiene'),
(Health, 'Health'),
(Lightning, 'Lightning'),
(Orientation, 'Orientation'),
(Tools, 'Tools'),
(Weapons, 'Weapons'),
]
category = models.CharField(choices=CATEGORIES, max_length=30)
name = models.CharField(blank=True, null=True, max_length=100)
weight = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
usefulness = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
external = models.BooleanField(blank=True, null=True, default=False)
climate = models.ManyToManyField(Climate, related_name='climates', blank=True)
landform = models.ManyToManyField(Landform, related_name='landforms', blank=True)
environment = models.ManyToManyField(Environment, related_name='environments', blank=True)
with_child = models.BooleanField(blank=True, null=True)
with_elder = models.BooleanField(blank=True, null=True)
with_pet = models.BooleanField(blank=True, null=True)
available_infrastructure = models.BooleanField(blank=True, null=True)
available_water = models.BooleanField(blank=True, null=True)
available_food = models.BooleanField(blank=True, null=True)
pass
# Serialize items for Bag object (ManyToMany relation)
class ItemSerializer(serializers.ModelSerializer):
climate = ClimateSerializer(many=True)
environment = EnvironmentSerializer(many=True)
landform = LandformSerializer(many=True)
class Meta:
model = Item
fields = '__all__'
depth = 2
# Bag object/model : Main object/model of the application
# => Aim of object/model :
# Capture details of bag packed for a given scenario (general details & related items)
# => Models/objects connected to Bag model/object via ManyToMany relation :
# Items
# => Models/objects connected to Bag model/object via ForeignKey relation :
# Climate, Landform, Environment, User (Owner)
class Bag(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
items = models.ManyToManyField(Item, related_name='items', blank=True)
name = models.CharField(blank=True, null=True, max_length=50)
weight_bag = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
weight_bag_actual = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
weight_user = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
climate = models.ForeignKey(Climate, on_delete=models.CASCADE)
landform = models.ForeignKey(Landform, on_delete=models.CASCADE)
environment = models.ForeignKey(Environment, on_delete=models.CASCADE)
with_child = models.BooleanField(blank=True, null=True)
with_elder = models.BooleanField(blank=True, null=True)
with_pet = models.BooleanField(blank=True, null=True)
available_infrastructure = models.BooleanField(blank=True, null=True)
available_water = models.BooleanField(blank=True, null=True)
available_food = models.BooleanField(blank=True, null=True)
# Feedback object/model
# => Aim of object/model :
# Capture details of feedback provided by the user about the site (rating & comment)
# => Models/objects connected to Feedback model/object via ForeignKey relation :
# User (Owner)
class Feedback(models.Model):
rating_point = models.IntegerField(null=True, blank=True)
rating_description = models.CharField(max_length=255, blank=True, null=True)
content = models.TextField(blank=True, null=True)
created = models.DateTimeField(auto_now_add=True, blank=True, null=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
# Recommendation object/model
# => Aim of object/model :
# Capture details of item recommended by a standard user for the approval of admin user
# => Models/objects connected to Recommendation model/object via ForeignKey relation :
# User (Owner)
class Recommendation(models.Model):
status = models.CharField(max_length=30, blank=True, null=True)
category = models.CharField(blank=True, null=True, max_length=100)
name = models.CharField(blank=True, null=True, max_length=100)
weight = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
usefulness = models.DecimalField(blank=True, max_digits=5, decimal_places=2, null=True)
external = models.BooleanField(blank=True, null=True, default=False)
justification = models.TextField(blank=True, null=True, max_length=600)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)