86c31d852e273119b309f57db84f7d9e8868a6be
2 # floof/floof/model/users.py
4 # Copyright (c) 2009 Scribblr
7 # from elixir import Entity, Field, Unicode, belongs_to, has_many
9 from search
import GalleryWidget
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")
21 def __unicode__(self
):
24 def __init__(self
, **kwargs
):
25 super(User
, self
).__init__(**kwargs
)
29 # TODO: have this clone a standard starter page
30 self
.primary_page
= UserPage(owner
=self
, title
="default", visible
=True)
32 # a starter gallery, just for fun
33 gallery
= GalleryWidget(owner
=self
, string
="awesome")
34 self
.primary_page
.galleries
.append(gallery
)
37 class IdentityURL(Entity
):
38 url
= Field(Unicode(255))
39 belongs_to('user', of_kind
='User')
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.
52 owner
= ManyToOne('User', inverse
="pages")
55 visible
= Field(Boolean
)
56 galleries
= OneToMany('GalleryWidget')