-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
111 lines (88 loc) · 4.14 KB
/
models.py
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
# -*- coding: utf-8 -*-
### coellection(django) ###
### GNU/GPL v2
### Author: Cody Rocker
### Author_email: [email protected]
### 2016
#-----------------------------------
# Requires: """
# - xlrd 0.9.4 """
# - Django 1.9.3 """
#-----------------------------------
from django.db import models
from django.core.urlresolvers import reverse
from django.template.defaultfilters import slugify
from .choices import *
class Platform(models.Model):
# Basic info
title = models.CharField(max_length=140)
upc = models.CharField(verbose_name='UPC', max_length=64, blank=True)
serial = models.CharField(max_length=64, blank=True)
model = models.CharField(max_length=64, blank=True)
modded = models.BooleanField(default=False)
slug = models.SlugField(default='', max_length=64, editable=False)
# Conditional ratings
plays = models.IntegerField(verbose_name='Works', choices=PLAYS_CHOICES, default=2)
box = models.IntegerField(choices=CONDITION_CHOICES, default=0)
manual = models.IntegerField(choices=CONDITION_CHOICES, default=0)
insert = models.IntegerField(choices=CONDITION_CHOICES, default=0)
vid_cable = models.IntegerField(verbose_name='Video Cable', choices=CONDITION_CHOICES, default=0)
pwr_cable = models.IntegerField(verbose_name='Power Cable', choices=CONDITION_CHOICES, default=0)
# Optional extras
donor = models.CharField(max_length=64, blank=True)
notes = models.TextField(blank=True)
def __str__(self):
return self.title
def get_absolute_url(self):
kwargs = {'slug': self.slug,}
return reverse('platform', kwargs=kwargs)
def save(self, *args, **kwargs):
self.slug = slugify(self.title[:64])
super(Platform, self).save(*args, **kwargs)
class Game(models.Model):
# Basic info
title = models.CharField(max_length=140)
platform = models.CharField(max_length=32, verbose_name='Platform', choices=PLATFORM_CHOICES)
upc = models.CharField(verbose_name='UPC', max_length=64, blank=True)
slug = models.SlugField(default='', max_length=64, editable=False)
# Conditional ratings
plays = models.IntegerField(verbose_name='Works', choices=PLAYS_CHOICES, default=2)
media_cond = models.IntegerField(choices=CONDITION_CHOICES, default=0)
label = models.IntegerField(choices=CONDITION_CHOICES, default=0)
dust_cover = models.IntegerField(choices=CONDITION_CHOICES, default=0)
box = models.IntegerField(choices=CONDITION_CHOICES, default=0)
c_box = models.BooleanField(verbose_name='Custom/Display Box', default=False)
manual = models.IntegerField(choices=CONDITION_CHOICES, default=0)
insert = models.IntegerField(choices=CONDITION_CHOICES, default=0)
battery = models.IntegerField(choices=CART_BATT_CHOICES, default=0)
# Optional extras
donor = models.CharField(max_length=64, blank=True)
notes = models.TextField(blank=True)
def __str__(self):
return '{0} ({1})'.format(self.title, self.get_platform_display())
def get_absolute_url(self):
kwargs = {'slug': self.slug,}
return reverse('game', kwargs=kwargs)
def save(self, *args, **kwargs):
self.slug = slugify(self.title[:64])
super(Game, self).save(*args, **kwargs)
class Amiibo(models.Model):
# Basic info
title = models.CharField(max_length=140)
upc = models.CharField(verbose_name='UPC', max_length=32, blank=True)
slug = models.SlugField(default='', max_length=64, editable=False)
# Conditional ratings
plays = models.IntegerField(verbose_name='Works', choices=PLAYS_CHOICES, default=2)
box = models.IntegerField(choices=CONDITION_CHOICES, default=0)
figure = models.IntegerField(choices=CONDITION_CHOICES, default=0)
# Optional extras
donor = models.CharField(max_length=64, blank=True)
notes = models.TextField(blank=True)
def __str__(self):
return self.title
def get_absolute_url(self):
kwargs = {'slug': self.slug,}
return reverse('amiibo', kwargs=kwargs)
def save(self, *args, **kwargs):
self.slug = slugify(self.title[:64])
super(Amiibo, self).save(*args, **kwargs)