merged in comments
[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 __init__(self, **kwargs):
25 super(User, self).__init__(**kwargs)
26
27
28
29 # TODO: have this clone a standard starter page
30 self.primary_page = UserPage(owner=self, title="default", visible=True)
31
32 # a starter gallery, just for fun
33 gallery = GalleryWidget(owner=self, string="awesome")
34 self.primary_page.galleries.append(gallery)
35
36
37 class IdentityURL(Entity):
38 url = Field(Unicode(255))
39 belongs_to('user', of_kind='User')
40
41
42
43 class UserPage(Entity):
44 """A user can have multiple pages, though by default they only have one visible.
45 This is so that they can keep some nice themed pages lying around for special occasions.
46 Page templates that provide familiar interfaces will also be UserPage records. Users will
47 see a panel full of them, and they can choose to clone those template pages to their own page list.
48 If more than one is set to visible, there would be tabs. The primary page is indicated in the user model.
49 """
50
51 owner = ManyToOne('User', inverse="pages")
52 title = Field(String)
53
54 visible = Field(Boolean)
55 galleries = OneToMany('GalleryWidget')
56
57
58
59
60 # class ArtRelation(Entity):
61 #