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
):
26 def __init__(self
, **kwargs
):
27 super(User
, self
).__init__(**kwargs
)
31 # TODO: have this clone a standard starter page
32 self
.primary_page
= UserPage(owner
=self
, title
="default", visible
=True)
34 # a starter gallery, just for fun
35 gallery
= GalleryWidget(owner
=self
, string
="awesome")
36 self
.primary_page
.galleries
.append(gallery
)
39 class IdentityURL(Entity
):
40 url
= Field(Unicode(255))
41 belongs_to('user', of_kind
='User')
45 class UserPage(Entity
):
46 """A user can have multiple pages, though by default they only have one visible.
47 This is so that they can keep some nice themed pages lying around for special occasions.
48 Page templates that provide familiar interfaces will also be UserPage records. Users will
49 see a panel full of them, and they can choose to clone those template pages to their own page list.
50 If more than one is set to visible, there would be tabs.
54 owner
= ManyToOne('User', inverse
="pages")
57 visible
= Field(Boolean
)
58 galleries
= OneToMany('GalleryWidget')
61 class UserRelationshipTypes(object):
64 class UserRelationship(Entity
):
65 """Represents some sort of connection between users.
67 For the moment, this means "watching". Later, it may mean friending or
70 XXX: Watching should be made more general than this; it should have the
71 power of an arbitrary query per watched artist without being unintelligible
75 user
= ManyToOne('User')
76 target_user
= ManyToOne('User')
77 type = Field(Integer
) # UserRelationshipTypes above