adding new art with user relations is there, sort of. Still needs adding relations...
[zzz-floof.git] / floof / model / users.py
1 #
2 # floof/floof/model/users.py
3 #
4 # Copyright (c) 2009 Scribblr
5 #
6
7 # from elixir import Entity, Field, Unicode, belongs_to, has_many
8 from elixir import *
9 from search import GalleryWidget
10
11 class User(Entity):
12 name = Field(Unicode(20))
13 uploads = OneToMany('Art')
14 has_many('identity_urls', of_kind='IdentityURL')
15 searches = OneToMany('SavedSearch')
16 # galleries = OneToMany('GalleryWidget')
17 pages = OneToMany('UserPage', inverse="owner")
18 primary_page = OneToOne('UserPage', inverse="owner")
19
20
21 def __unicode__(self):
22 return self.name
23
24 def __str__(self):
25 return self.name
26
27 def __init__(self, **kwargs):
28 super(User, self).__init__(**kwargs)
29
30
31
32 # TODO: have this clone a standard starter page
33 self.primary_page = UserPage(owner=self, title="default", visible=True)
34
35 # a starter gallery, just for fun
36 gallery = GalleryWidget(owner=self, string="awesome")
37 self.primary_page.galleries.append(gallery)
38
39
40 class IdentityURL(Entity):
41 url = Field(Unicode(255))
42 belongs_to('user', of_kind='User')
43
44
45
46 class UserPage(Entity):
47 """A user can have multiple pages, though by default they only have one visible.
48 This is so that they can keep some nice themed pages lying around for special occasions.
49 Page templates that provide familiar interfaces will also be UserPage records. Users will
50 see a panel full of them, and they can choose to clone those template pages to their own page list.
51 If more than one is set to visible, there would be tabs. The primary page is indicated in the user model.
52 """
53
54 owner = ManyToOne('User', inverse="pages")
55 title = Field(String)
56
57 visible = Field(Boolean)
58 galleries = OneToMany('GalleryWidget')
59
60
61
62
63 # class ArtRelation(Entity):
64 #