1 | from django.db import models
|
---|
2 | from django.contrib.auth.models import User
|
---|
3 |
|
---|
4 | class GameGenre( models.Model ):
|
---|
5 | class Admin:
|
---|
6 | pass
|
---|
7 |
|
---|
8 | class Meta:
|
---|
9 | ordering = ( 'sort_order', )
|
---|
10 |
|
---|
11 | def __str__( self ):
|
---|
12 | return self.name
|
---|
13 |
|
---|
14 | name = models.CharField( maxlength=60)
|
---|
15 | sort_order = models.PositiveSmallIntegerField()
|
---|
16 |
|
---|
17 |
|
---|
18 | class Game( models.Model ):
|
---|
19 | class Admin:
|
---|
20 | pass
|
---|
21 |
|
---|
22 | class Meta:
|
---|
23 | ordering = ( 'name', )
|
---|
24 |
|
---|
25 | def __str__( self ):
|
---|
26 | return self.name
|
---|
27 |
|
---|
28 | name = models.CharField( maxlength=60 )
|
---|
29 | genre = models.ForeignKey( GameGenre )
|
---|
30 |
|
---|
31 |
|
---|
32 | class Profile( models.Model ):
|
---|
33 | class Admin:
|
---|
34 | pass
|
---|
35 |
|
---|
36 | def __str__( self ):
|
---|
37 | return self.user.username
|
---|
38 |
|
---|
39 | user = models.ForeignKey( User, unique=True, edit_inline=models.STACKED,
|
---|
40 | max_num_in_admin=1, num_in_admin=1, core=True )
|
---|
41 | description = models.TextField( blank=True)
|
---|
42 | city = models.CharField( maxlength=30, blank=True )
|
---|
43 | state_province = models.CharField( "State or province", maxlength=30, blank=True ) # TODO make state_province table (can't use USStateField)
|
---|
44 | country = models.CharField( maxlength=30, blank=True ) # TODO make Country table
|
---|
45 | zip_code = models.CharField( maxlength=10, blank=True ) # TODO need to write your own validator (see validator docs)
|
---|
46 |
|
---|
47 | genres_of_interest = models.ManyToManyField( GameGenre, blank=True )
|
---|
48 |
|
---|
49 |
|
---|
50 | class GameOfInterest( models.Model ):
|
---|
51 | class Admin:
|
---|
52 | pass
|
---|
53 |
|
---|
54 | def __str__( self ):
|
---|
55 | return self.game.name
|
---|
56 |
|
---|
57 | game = models.ForeignKey( Game, blank=False )
|
---|
58 | profile = models.ForeignKey( Profile, edit_inline=models.TABULAR, num_in_admin=1, core=True, blank=False )
|
---|
59 | own = models.BooleanField()
|
---|
60 | wish_to_play = models.BooleanField()
|
---|
61 | willing_to_play = models.BooleanField()
|
---|