Models
Dependencies
SingletonModel
Model representing a singleton model.
Attributes:
Source code in backend/api/models.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
save(*args, **kwargs)
Override save method to validate only one instance exists.
Source code in backend/api/models.py
23 24 25 26 27 28 29 | |
delete(*args, **kwargs)
Override delete method to block deletes.
Source code in backend/api/models.py
31 32 33 34 35 | |
Store
Store
Model representing a Store.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of a store. Required. Unique. |
Source code in backend/api/models.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The Store Object name. |
Source code in backend/api/models.py
48 49 50 51 52 53 | |
Aisle
Aisle
Model representing an aisle in a store.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of the Aisle. |
order |
IntegerField
|
The order of appearance for Aisle. |
store |
Store
|
An object respresenting a store. |
Source code in backend/api/models.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The Aisle Object name. |
Source code in backend/api/models.py
70 71 72 73 74 75 | |
Item
Item
Model representing an item.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of the Item. Unique. |
matches |
CharField
|
Alternate spelling that matches. |
plural |
CharField
|
Plural spelling of item name. |
aisle |
Aisle
|
An object representing an aisle. |
image |
ImageField
|
A photo of the item, for telling it apart from similar products on a shelf. Optional. |
thumbnail |
ImageField
|
The downscaled rendition shown on list rows.
Written by the upload endpoint alongside |
Source code in backend/api/models.py
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 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The Item Object name. |
Source code in backend/api/models.py
103 104 105 106 107 108 | |
ShoppingList
ShoppingList
Model representing a ShopingList object.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of the shopping list. |
store |
Store
|
An object representing a store. |
Source code in backend/api/models.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The ShoppingList Object name. |
Source code in backend/api/models.py
123 124 125 126 127 128 | |
ListItem
ListItem
Model representing a ListItem object.
Attributes:
| Name | Type | Description |
|---|---|---|
qty |
IntegerField
|
The numder of items for this list item. |
purchased |
BooleanField
|
Wether this list item has been purchased. |
notes |
TextField
|
Notes associated with this list item. |
purch_date(DateFild) |
TextField
|
The date this list item was purchased. |
item |
Item
|
An object representing an Item. |
aisle |
Aisle
|
An object representing an Aisle. |
shopping_list |
ShoppingList
|
An object representing a ShoppingList. |
Source code in backend/api/models.py
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 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The ListItem Object name. |
Source code in backend/api/models.py
156 157 158 159 160 161 | |
Freezer
Freezer
Model representing a Freezer.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of the freezer. Required. Unique. |
location |
CharField
|
Where the freezer is, eg. "Garage". Optional. |
Source code in backend/api/models.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The Freezer Object name. |
Source code in backend/api/models.py
176 177 178 179 180 181 | |
FreezerItem
FreezerItem
Model representing a frozen food stored in a Freezer.
Unlike ListItem, this does not reference the Item catalog. Freezer contents are often one-off leftovers ("chili, Nov 3") that would only pollute the shopping list catalog if they were forced into it.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
CharField
|
The name of the frozen food. |
qty |
IntegerField
|
How much is stored. Default = 1. |
unit |
CharField
|
The unit for qty, eg. "lbs", "bags". Optional. |
date_added |
DateField
|
The date this was put in the freezer. Optional, since food already in the freezer often has no date on it. |
discard_date |
DateField
|
The date this should be thrown out. Optional. |
notes |
TextField
|
Notes associated with this frozen food. |
freezer |
Freezer
|
An object representing a Freezer. |
image |
ImageField
|
A photo of the frozen food. Optional, and carried here rather than on Item because FreezerItem has no Item FK. |
thumbnail |
ImageField
|
The downscaled rendition shown on freezer rows.
Written by the upload endpoint alongside |
Source code in backend/api/models.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The FreezerItem Object name. |
Source code in backend/api/models.py
247 248 249 250 251 252 | |
FreezerLog
FreezerLog
Model representing something that happened to a frozen food.
Answers "what happened to that meatloaf?" months later, so it is written to be readable on its own: the food's name, its unit and the freezer names are copied in as text rather than followed through a FK. A FreezerItem is deleted the moment the last of it is used, which is precisely when its log entries become interesting, so a cascade would erase the answer along with the question.
The FKs are kept as a convenience for as long as the rows survive, and go null rather than taking the log with them.
Attributes:
| Name | Type | Description |
|---|---|---|
action |
CharField
|
What happened — one of ACTION_CHOICES. |
name |
CharField
|
The food's name when the event happened. |
qty |
IntegerField
|
How many the event concerned. For a use or a move this is the number used or moved, not the number remaining. |
unit |
CharField
|
The unit for qty, copied from the food. Optional. |
freezer_name |
CharField
|
The freezer this happened in, as text. |
to_freezer_name |
CharField
|
Where a move sent it, as text. None for every other action. |
freezer |
Freezer
|
The freezer, while it still exists. Optional. |
freezeritem |
FreezerItem
|
The food, while it still exists. Optional, and null for anything used up, thrown out or since deleted. |
occurred |
DateTimeField
|
When it happened. Set once, on write. |
Source code in backend/api/models.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The FreezerLog Object description. |
Source code in backend/api/models.py
360 361 362 363 364 365 | |
Version
Version
Model representing app version.
Fields: - version_number (CharField): The current version of the app.
Source code in backend/api/models.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
__str__()
Returns:
| Type | Description |
|---|---|
String
|
The version number. |
Source code in backend/api/models.py
378 379 380 381 382 383 | |