@@ -638,16 +638,6 @@ def sessions_that_can_meet(self):
638638 self ._cached_sessions_that_can_meet = self .meeting .sessions_that_can_meet .all ()
639639 return self ._cached_sessions_that_can_meet
640640
641- def area_list (self ):
642- return ( self .assignments .filter (session__group__type__slug__in = ['wg' , 'rg' , 'ag' , 'iab' ],
643- session__group__parent__isnull = False )
644- .order_by ('session__group__parent__acronym' )
645- .values_list ('session__group__parent__acronym' , flat = True )
646- .distinct () )
647-
648- def groups (self ):
649- return Group .objects .filter (type__slug__in = ['wg' , 'rg' , 'ag' , 'iab' ], parent__isnull = False , session__scheduledsession__schedule = self ).exclude (session__scheduledsession__timeslot__type__in = ['lead' ,'offagenda' ]).distinct ().order_by ('parent__acronym' , 'acronym' )
650-
651641 # calculate badness of entire schedule
652642 def calc_badness (self ):
653643 # now calculate badness
@@ -768,6 +758,35 @@ def json_dict(self, host_scheme):
768758 ss ["pinned" ] = self .pinned
769759 return ss
770760
761+ def slug (self ):
762+ """Return sensible id string for session, e.g. suitable for use as HTML anchor."""
763+ components = []
764+
765+ if not self .timeslot :
766+ components .append ("unknown" )
767+
768+ if not self .session or not (getattr (self .session , "historic_group" ) or self .session .group ):
769+ components .append ("unknown" )
770+ else :
771+ components .append (self .timeslot .time .strftime ("%a-%H%M" ))
772+
773+ g = getattr (self .session , "historic_group" , None ) or self .session .group
774+
775+ if self .timeslot .type_id in ('break' , 'reg' , 'other' ):
776+ components .append (g .acronym )
777+
778+ if self .timeslot .type_id in ('session' , 'plenary' ):
779+ if self .timeslot .type_id == "plenary" :
780+ components .append ("1plenary" )
781+ else :
782+ p = getattr (g , "historic_parent" , None ) or g .parent
783+ if p and p .type_id in ("area" , "irtf" ):
784+ components .append (p .acronym )
785+
786+ components .append (g .acronym )
787+
788+ return u"-" .join (components ).lower ()
789+
771790class Constraint (models .Model ):
772791 """
773792 Specifies a constraint on the scheduling.
@@ -886,14 +905,30 @@ class Session(models.Model):
886905
887906 # Should work on how materials are captured so that deleted things are no longer associated with the session
888907 # (We can keep the information about something being added to and removed from a session in the document's history)
908+ def get_material (self , material_type , only_one ):
909+ if hasattr (self , "prefetched_active_materials" ):
910+ l = [d for d in self .prefetched_active_materials if d .type_id == material_type ]
911+ for d in l :
912+ d .meeting_related = lambda : True
913+ else :
914+ l = self .materials .filter (type = material_type ).exclude (states__type = material_type , states__slug = 'deleted' ).order_by ("order" )
915+
916+ if only_one :
917+ if l :
918+ return l [0 ]
919+ else :
920+ return None
921+ else :
922+ return l
923+
889924 def agenda (self ):
890- return self .materials . filter ( type = ' agenda' ). exclude ( states__type = 'agenda' , states__slug = 'deleted' ). first ( )
925+ return self .get_material ( " agenda" , only_one = True )
891926
892927 def minutes (self ):
893- return self .materials . filter ( type = ' minutes' ). exclude ( states__type = 'minutes' , states__slug = 'deleted' ). first ( )
928+ return self .get_material ( " minutes" , only_one = True )
894929
895930 def slides (self ):
896- return list (self .materials . filter ( type = ' slides' ). exclude ( states__type = 'slides' , states__slug = 'deleted' ). order_by ( 'order' ))
931+ return list (self .get_material ( " slides" , only_one = False ))
897932
898933 def __unicode__ (self ):
899934 if self .meeting .type_id == "interim" :
@@ -908,9 +943,6 @@ def __unicode__(self):
908943 ss0name = ',' .join ([x .timeslot .time .strftime ("%a-%H%M" ) for x in ss ])
909944 return u"%s: %s %s %s" % (self .meeting , self .group .acronym , self .name , ss0name )
910945
911- def is_bof (self ):
912- return self .group .is_bof ();
913-
914946 @property
915947 def short_name (self ):
916948 if self .name :
@@ -994,7 +1026,7 @@ def json_dict(self, host_scheme):
9941026 sess1 ['name' ] = str (self .name )
9951027 sess1 ['title' ] = str (self .short_name )
9961028 sess1 ['short_name' ] = str (self .short_name )
997- sess1 ['bof' ] = str (self .is_bof ())
1029+ sess1 ['bof' ] = str (self .group . is_bof ())
9981030 sess1 ['agenda_note' ] = str (self .agenda_note )
9991031 sess1 ['attendees' ] = str (self .attendees )
10001032 sess1 ['status' ] = str (self .status )
@@ -1024,18 +1056,6 @@ def agenda_text(self):
10241056 else :
10251057 return "The agenda has not been uploaded yet."
10261058
1027- # FIXME - This used to be called 'type'. It is only used in agenda.csv and agenda.txt.
1028- # It will return the _wrong thing_ if you look back at an agenda of an earlier meeting
1029- # where group X was a BOF at the time, but is now a WG.
1030- # It also doesn't return anything useful for RG, area sessions, or anything that's not group type 'wg'.
1031- # A better thing to do is find a way to note when a meeting was a BoF meeting and use that, removing this
1032- # function altogether.
1033- def lame_description (self ):
1034- if self .group .type .slug in [ "wg" ]:
1035- return "BOF" if self .group .state .slug in ["bof" , "bof-conc" ] else "WG"
1036- else :
1037- return ""
1038-
10391059 def ical_status (self ):
10401060 if self .status .slug == 'canceled' : # sic
10411061 return "CANCELLED"
@@ -1050,13 +1070,13 @@ def agenda_file(self):
10501070 if not hasattr (self , '_agenda_file' ):
10511071 self ._agenda_file = ""
10521072
1053- docs = self .materials . filter ( type = " agenda" , states__type = "agenda" , states__slug = "active" )
1054- if not docs :
1073+ agenda = self .agenda ( )
1074+ if not agenda :
10551075 return ""
10561076
10571077 # we use external_url at the moment, should probably regularize
10581078 # the filenames to match the document name instead
1059- filename = docs [ 0 ] .external_url
1079+ filename = agenda .external_url
10601080 self ._agenda_file = "%s/agenda/%s" % (self .meeting .number , filename )
10611081
10621082 return self ._agenda_file
0 commit comments