Added Fugue icon set, version 2.4.3.
[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 relationships = OneToMany('UserRelationship', inverse='user')
20 target_of_relationships = OneToMany('UserRelationship', inverse='target_user')
21
22
23 def __unicode__(self):
24 return self.name
25
26 def __init__(self, **kwargs):
27 super(User, self).__init__(**kwargs)
28
29
30
31 # TODO: have this clone a standard starter page
32 self.primary_page = UserPage(owner=self, title="default", visible=True)
33
34 # a starter gallery, just for fun
35 gallery = GalleryWidget(owner=self, string="awesome")
36 self.primary_page.galleries.append(gallery)
37
38
39 class IdentityURL(Entity):
40 url = Field(Unicode(255))
41 belongs_to('user', of_kind='User')
42
43
44
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.
51
52 """
53
54 owner = ManyToOne('User', inverse="pages")
55 title = Field(String)
56
57 visible = Field(Boolean)
58 galleries = OneToMany('GalleryWidget')
59
60
61 class UserRelationshipTypes(object):
62 IS_WATCHING = 1
63
64 class UserRelationship(Entity):
65 """Represents some sort of connection between users.
66
67 For the moment, this means "watching". Later, it may mean friending or
68 ignoring.
69
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
72 to users.
73 """
74
75 user = ManyToOne('User')
76 target_user = ManyToOne('User')
77 type = Field(Integer) # UserRelationshipTypes above