app/soc/views/models/notification.py
changeset 727 ddf44af087a0
parent 726 ba3d399ec9be
child 732 0a8e60228311
equal deleted inserted replaced
726:ba3d399ec9be 727:ddf44af087a0
   166     """
   166     """
   167     
   167     
   168     params = dicts.merge(params, self._params)
   168     params = dicts.merge(params, self._params)
   169       
   169       
   170     # get the current user
   170     # get the current user
   171     properties = {'account': users.get_current_user()}
   171     user_entity = user_logic.logic.getForCurrentAccount()
   172     user_entity = user_logic.logic.getForFields(properties, unique=True)
       
   173 
   172 
   174     # only select the notifications for this user so construct a filter
   173     # only select the notifications for this user so construct a filter
   175     filter = {'scope': user_entity}
   174     filter = {'scope': user_entity}
   176     
   175     
   177     # create the list parameters
   176     # create the list parameters
   191       
   190       
   192   def _editPost(self, request, entity, fields):
   191   def _editPost(self, request, entity, fields):
   193     """See base.View._editPost().
   192     """See base.View._editPost().
   194     """
   193     """
   195 
   194 
   196     account = users.get_current_user()
   195     # get the current user
   197     current_user = user_logic.logic.getForFields({'account': account}, unique=True)
   196     current_user = user_logic.logic.getForCurrentAccount()
   198     
   197     
   199     to_user = user_logic.logic.getForFields(
   198     to_user = user_logic.logic.getForFields(
   200         {'link_id' : fields['to_user']}, unique=True)
   199         {'link_id' : fields['to_user']}, unique=True)
   201 
   200 
   202     fields['link_id'] = '%i' %(time.time())
   201     fields['link_id'] = '%i' %(time.time())
   223     
   222     
   224     # if the user viewing is the user for which this notification is meant
   223     # if the user viewing is the user for which this notification is meant
   225     # and the notification has not been read yet
   224     # and the notification has not been read yet
   226     if not entity.has_been_read:
   225     if not entity.has_been_read:
   227       # get the current user
   226       # get the current user
   228       account = users.get_current_user()
   227       user = user_logic.logic.getForCurrentAccount()
   229       user = user_logic.logic.getForFields({'account': account}, unique=True)
       
   230       
   228       
   231       if entity.scope.key() == user.key():
   229       if entity.scope.key() == user.key():
   232       # mark the entity as read
   230         # mark the entity as read
   233         self._logic.updateModelProperties(entity, {'has_been_read' : True} )
   231         self._logic.updateModelProperties(entity, {'has_been_read' : True} )
   234     
   232     
   235     context['entity_type_url'] = self._params['url_name']
   233     context['entity_type_url'] = self._params['url_name']
   236     context['entity_suffix'] = self._logic.getKeySuffix(entity)
   234     context['entity_suffix'] = self._logic.getKeySuffix(entity)
   237 
   235