コード例 #1
0
ファイル: cases.py プロジェクト: umeboshi2/mslemon
 def attach_user(self, case_id, user_id):
     user = self.session.query(CaseUser).get((case_id, user_id))
     if user is None:
         with transaction.manager:
             now = datetime.now()
             cu = CaseUser()
             cu.case_id = case_id
             cu.user_id = user_id
             self.session.add(cu)
         user = self.session.merge(cu)
         reason = "Added User to Case"
         status = "pending"
         current = self.session.query(CaseCurrentStatus).get(case_id)
         handler_id = current.handler_id
         self.update_case(case_id, user_id, status, reason, handler_id)
     return user    
コード例 #2
0
ファイル: cases.py プロジェクト: umeboshi2/mslemon
 def open_case(self, name, description, client_id,
               user_id, handler_id=None):
     if handler_id is None:
         handler_id = user_id
     d = self.descriptions.new(description)
     with transaction.manager:
         now = datetime.now()
         c = Case()
         c.name = name
         c.client_id = client_id
         c.description_id = d.id
         c.created = now
         c.created_by_id = user_id
         self.session.add(c)
         c = self.session.merge(c)
         change = CaseStatusChange()
         change.case_id = c.id
         change.status = 'opened'
         change.reason = 'New Case'
         change.description_id = d.id
         change.changed = now
         change.changed_by_id = user_id
         change.handler_id = handler_id
         self.session.add(change)
         change = self.session.merge(change)
         current = CaseCurrentStatus()
         current.case_id = c.id
         current.last_change_id = change.id
         current.created = c.created
         current.last_change = change.changed
         current.status = change.status
         current.changed_by_id = user_id
         current.handler_id = handler_id
         self.session.add(current)
         cu = CaseUser()
         cu.case_id = c.id
         cu.user_id = user_id
         self.session.add(cu)
     return self.session.merge(c)