back-up commit. probably broken.
[TownSquare.git] / townsquare / model / channel.py
bloba8c649803d4cac1681768baeca5f48c3723e0c54
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'
10 @property
11 def url(self):
12 return '/channel/' + str(self._id)
14 def get_short_description(self):
15 if not hasattr(self, 'description'):
16 return ''
17 if len(self.description) < 140:
18 return self.description
19 #TODO: truncate string
20 desc = self.description
21 iend = desc.rfind(' ', 0, 137)
22 if iend < 0:
23 desc = "%s..." % desc[0:137]
24 else:
25 desc = "%s..." % desc[0:iend]
26 #TODO: find the last space or return as-is if no spaces within
27 return desc
29 def save(self):
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?)
33 pass
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
39 pass
40 super(Channel, self).save()