app/soc/logic/models/request.py
changeset 1948 25cd704fdfdf
parent 1308 35b75ffcbb37
child 1954 7aef36e912bb
equal deleted inserted replaced
1947:af360d1017df 1948:25cd704fdfdf
    56   def getKeyFieldNames(self):
    56   def getKeyFieldNames(self):
    57     """See base.Logic.getKeyFieldNames.
    57     """See base.Logic.getKeyFieldNames.
    58     """
    58     """
    59 
    59 
    60     return ['scope_path', 'role', 'link_id']
    60     return ['scope_path', 'role', 'link_id']
    61   
    61 
    62   def _onCreate(self, entity):
    62   def _onCreate(self, entity):
    63     """Sends out a message notifying users about the new invite/request.
    63     """Sends out a message notifying users about the new invite/request.
    64     """
    64     """
    65 
    65 
    66     if entity.status == 'group_accepted':
    66     if entity.status == 'group_accepted':
    71       # TODO(Lennard) Create a new request message
    71       # TODO(Lennard) Create a new request message
    72       pass
    72       pass
    73 
    73 
    74     super(Logic, self)._onCreate(entity)
    74     super(Logic, self)._onCreate(entity)
    75 
    75 
       
    76   def _updateField(self, entity, entity_properties, name):
       
    77     """Called when the fields of the request are updated.
       
    78 
       
    79       - Sends out a message depending on the change of status
       
    80     """
       
    81 
       
    82     value = entity_properties[name]
       
    83 
       
    84     if name == 'status' and entity.status != value:
       
    85       if value == 'group_accepted':
       
    86        # this is an invite
       
    87         notifications.sendInviteNotification(entity)
       
    88       elif value == 'new':
       
    89         # this is a request
       
    90         # TODO(Lennard) Create a new request message
       
    91         pass
       
    92 
       
    93     return super(Logic, self)._updateField(entity, entity_properties, name)
       
    94 
    76 
    95 
    77 logic = Logic()
    96 logic = Logic()