7601cf5072e442a7c124f5e0d329bd5dde573676
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")
19 relationships
= OneToMany('UserRelationship', inverse
='user')
20 target_of_relationships
= OneToMany('UserRelationship', inverse
='target_user')
23 def __unicode__(self
):
29 def __init__(self
, **kwargs
):
30 super(User
, self
).__init__(**kwargs
)
34 # TODO: have this clone a standard starter page
35 self
.primary_page
= UserPage(owner
=self
, title
="default", visible
=True)
37 # a starter gallery, just for fun
38 gallery
= GalleryWidget(owner
=self
, string
="awesome")
39 self
.primary_page
.galleries
.append(gallery
)
42 class IdentityURL(Entity
):
43 url
= Field(Unicode(255))
44 belongs_to('user', of_kind
='User')
48 class UserPage(Entity
):
49 """A user can have multiple pages, though by default they only have one visible.
50 This is so that they can keep some nice themed pages lying around for special occasions.
51 Page templates that provide familiar interfaces will also be UserPage records. Users will
52 see a panel full of them, and they can choose to clone those template pages to their own page list.
53 If more than one is set to visible, there would be tabs. The primary page is indicated in the user model.
56 owner
= ManyToOne('User', inverse
="pages")
59 visible
= Field(Boolean
)
60 galleries
= OneToMany('GalleryWidget')
63 class UserRelationshipTypes(object):
66 class UserRelationship(Entity
):
67 """Represents some sort of connection between users.
69 For the moment, this means "watching". Later, it may mean friending or
72 XXX: Watching should be made more general than this; it should have the
73 power of an arbitrary query per watched artist without being unintelligible
77 user
= ManyToOne('User')
78 target_user
= ManyToOne('User')
79 type = Field(Integer
) # UserRelationshipTypes above