2 from fma
import SuperDoc
3 from fma
.orm
import relation
5 #TODO: membership/subscription, member roles
6 #CHECK: allow markdown in the description?
7 class Channel(SuperDoc
):
8 _collection_name
= 'channels'
12 return '/channel/' + str(self
._id
)
14 def get_short_description(self
):
15 if not hasattr(self
, 'description'):
17 if len(self
.description
) < 140:
18 return self
.description
19 #TODO: truncate string
20 desc
= self
.description
21 iend
= desc
.rfind(' ', 0, 137)
23 desc
= "%s..." % desc
[0:137]
25 desc
= "%s..." % desc
[0:iend
]
26 #TODO: find the last space or return as-is if no spaces within
30 #TODO: check attributes
31 if self
.name
is None or len(self
.name
) is 0:
32 #TODO: take the name from the few first words of the description (or bail out?)
34 if self
.idname
is None or len(self
.idname
) is 0:
35 #TODO: generate idname (case-insensitive unique url-safe name) from title (name)
36 # if the idname is not provided generate it from name
37 # if the generated idname conflicts with existing one, add serial (dunno how to track the existing serials)
38 # if the idname is provided but that idname is already exists, bail out
40 super(Channel
, self
).save()