File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import datetime
44import email .utils
5+ import re
56from urlparse import urljoin
67
78from django .db import models
@@ -168,6 +169,22 @@ def status_for_meeting(self,meeting):
168169 status_events = status_events .filter (time__gte = previous_meeting .end_date ()+ datetime .timedelta (days = 1 ))
169170 return status_events .first ()
170171
172+ def get_description (self ):
173+ """
174+ Return self.description if set, otherwise the first paragraph of the
175+ charter if any, else a short error message. Used to provide a
176+ fallback for self.description in group.resources.GroupResource.
177+ """
178+ desc = 'No description available'
179+ if self .description :
180+ desc = self .description
181+ elif self .charter :
182+ text = self .charter .text ()
183+ # split into paragraphs and grab the first non-empty one
184+ if text :
185+ desc = [ p for p in re .split ('\r ?\n \s*\r ?\n \s*' , text ) if p .strip () ][0 ]
186+ return desc
187+
171188class GroupHistory (GroupInfo ):
172189 group = models .ForeignKey (Group , related_name = 'history_set' )
173190 acronym = models .CharField (max_length = 40 )
Original file line number Diff line number Diff line change 11# Autogenerated by the mkresources management command 2014-11-13 23:15
22from ietf .api import ModelResource
33from ietf .api import ToOneField
4- from tastypie .fields import ToManyField
4+ from tastypie .fields import ToManyField , CharField
55from tastypie .constants import ALL , ALL_WITH_RELATIONS
66from tastypie .cache import SimpleCache
77
@@ -22,6 +22,7 @@ class GroupResource(ModelResource):
2222 charter = ToOneField ('ietf.doc.resources.DocumentResource' , 'charter' , null = True )
2323 unused_states = ToManyField ('ietf.doc.resources.StateResource' , 'unused_states' , null = True )
2424 unused_tags = ToManyField (DocTagNameResource , 'unused_tags' , null = True )
25+ description = CharField (attribute = 'get_description' )
2526 class Meta :
2627 cache = SimpleCache ()
2728 queryset = Group .objects .all ()
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ def make_test_data():
133133 group = Group .objects .create (
134134 name = "Martian Special Interest Group" ,
135135 acronym = "mars" ,
136+ description = "This group discusses mars issues." ,
136137 state_id = "active" ,
137138 type_id = "wg" ,
138139 parent = area ,
@@ -159,6 +160,7 @@ def make_test_data():
159160 group = Group .objects .create (
160161 name = "Asteroid Mining Equipment Standardization Group" ,
161162 acronym = "ames" ,
163+ description = "This group works towards standardization of asteroid mining equipment." ,
162164 state_id = "proposed" ,
163165 type_id = "wg" ,
164166 parent = area ,
@@ -185,6 +187,7 @@ def make_test_data():
185187 frfarea = Group .objects .create (
186188 name = "Far Future Area Group" ,
187189 acronym = "frfarea" ,
190+ description = "This group discusses future space colonization issues." ,
188191 state_id = "active" ,
189192 type_id = "ag" ,
190193 parent = area ,
@@ -195,6 +198,7 @@ def make_test_data():
195198 irg_rg = Group .objects .create (
196199 name = "Internet Research Group" ,
197200 acronym = "irg" ,
201+ description = "This group handles internet research." ,
198202 state_id = "active" ,
199203 type_id = "rg" ,
200204 parent = irtf ,
You can’t perform that action at this time.
0 commit comments