Beispiel #1
0
    def _perform_request(self, user, attr, deadline_id, value):
        notes = value[0].decode("utf-8")

        deadline_repo = DeadlineRepository()
        dead = deadline_repo.deadline_for_user(user.id, deadline_id)
        dead.meta.notes = notes
        deadline_repo.persist(dead)
        deadline_repo.close()
Beispiel #2
0
    def _perform_request(self, user, attr, deadline_id, value):
        new_name = value[0].decode("utf-8")

        deadline_repo = DeadlineRepository()
        dd = deadline_repo.deadline_for_user(user.id, deadline_id)
        dd.name = new_name
        deadline_repo.persist(dd)
        deadline_repo.close()
Beispiel #3
0
    def _perform_request(self, user, attr, deadline_id, value):
        new_time = value[0].decode("utf-8")
        # Strip the 0000- year off the time.
        new_time = datetime.strptime(new_time[5:], "%m-%d %H:%M")
        # Add the correct year
        new_time = new_time + (date(datetime.now().year, 1, 1) - date(new_time.year, 1, 1))

        deadline_repo = DeadlineRepository()
        dead = deadline_repo.deadline_for_user(user.id, deadline_id)
        dead.deadline = new_time
        deadline_repo.persist(dead)
        deadline_repo.close()
Beispiel #4
0
    def _perform_request(self, user, name, values):
        group_id = values[u"group_id"]
        name = values[u"name"]
        deadline = values[u"deadline"]
        notes = values[u"notes"]
        curr_user = self.get_current_user()

        dr = DeadlineRepository()
        gr = GroupRepository()
        group = gr.fetch(group_id)
        gr.get_group_maintainer(group)

        new_deadline = Deadline()
        new_deadline.meta = DeadlineMetadata()

        new_deadline.name = name
        new_deadline.group_id = group_id
        new_deadline.deadline = datetime.strptime(deadline, u'%m/%d/%Y %I:%M %p') # private group
        if(group.maintainer and group.maintainer.id == user.id):
            new_deadline.type = 'END'
        else:
            new_deadline.type = 'PER'
        new_deadline.meta.user_id = user.id
        new_deadline.meta.notes = notes
        new_deadline = dr.persist(new_deadline)

        dr.close()

        result = {}

        result['id'] = new_deadline.id
        result['name'] = new_deadline.name
        result['group'] = new_deadline.group
        result['type'] = new_deadline.type
        result['time'] = new_deadline.deadline.strftime(u'%A %b %d, %H:%M')
        result['notes'] = new_deadline.meta.notes
        result['can_edit'] = (new_deadline.type == "PER" or (group.maintainerId == user.id and new_deadline.type == "END"))

        self.write(json.dumps(result))
        self.flush
        self.finish