5 class UserRelation(Entity
):
6 user
= ManyToOne("User")
8 kind
= Field(String
) # by for of
9 creator
= ManyToOne("User")
10 confirmed_by_related_user
= Field(Boolean
)
12 # it is useful to record which authority figure on a given artwork
13 # confirmed the validity of this relation.
14 confirmed_by_authority
= ManyToOne("User")
16 def __init__(self
, **kwargs
):
17 super(UserRelation
, self
).__init__(**kwargs
)
18 assert self
.user
and self
.art
and self
.kind
and self
.creator
20 if self
.creator
== self
.user
:
21 self
.confirmed_by_related_user
= True
22 # TODO: implement authorities
23 # if self.creator in self.art.authorities
24 # self.confirmed_by_authority = self.creator
26 def __unicode__(self
):
27 return "%s: %s" %
(self
.kind
, self
.related_user
)
30 class RelationMixin(object):
31 def add_relation(creator
, kind
, user
):
32 return UserRelation(art
=self
, creator
=creator
, kind
=kind
, user
=user
)
34 Art
.__bases__
+= (RelationMixin
,)