예제 #1
0
 def app_states(self):
     app = ISchoolToolApplication(None)
     container = IRelationshipStateContainer(app)
     states = container.get(self.view.app_states_name, None)
     if states is None:
         return {}
     return states
예제 #2
0
 def getVocabulary(self):
     app = ISchoolToolApplication(None)
     container = IRelationshipStateContainer(app)
     relationships = container.get(self.field.source)
     terms = [
         zope.schema.vocabulary.SimpleTerm(state,
                                           token=state.__name__,
                                           title=state.title)
         for state in relationships.states.values()
     ]
     vocabulary = zope.schema.vocabulary.SimpleVocabulary(terms)
     return vocabulary
예제 #3
0
 def __call__(self):
     if self.states_name is None:
         raise NotImplementedError()
     container = IRelationshipStateContainer(self.app)
     if self.states_name not in container:
         try:
             container[self.states_name] = self.create(self.states_title)
             self.populate(container[self.states_name])
         except Exception, e:
             try:
                 del container[self.states_name]
             except Exception:
                 pass
             raise e
예제 #4
0
 def states(self):
     if self.app_states_name is None:
         return None
     app = ISchoolToolApplication(None)
     container = IRelationshipStateContainer(app)
     return container.get(self.app_states_name, None)
예제 #5
0
 def container(self):
     app = ISchoolToolApplication(None)
     return IRelationshipStateContainer(app)
예제 #6
0
def getAppContactStates():
    app = ISchoolToolApplication(None)
    container = IRelationshipStateContainer(app)
    app_states = container['contact-relationship']
    return app_states
예제 #7
0
 def app_states(self, key):
     app = ISchoolToolApplication(None)
     states = IRelationshipStateContainer(app)[key]
     return states
예제 #8
0
 def completed_state_codes(self):
     app = ISchoolToolApplication(None)
     states = IRelationshipStateContainer(app)['section-membership']
     codes = [state.code for state in states
              if states.overlap(COMPLETED, state.active)]
     return codes