Пример #1
0
    def add(self, **data):
        """Add a project"""
        project = Project()
        project.creator = self.request.principal.title
        project.creation_date = datetime.datetime.now()
        project.modification_date = datetime.datetime.now()
        self.applyData(project, **data)

        title = data['title']
        suffix = 1
        id = normalize(title)
        while id in self.context:
            title += str(suffix)
            suffix += 1
            id = normalize(title)

        project.id = id
        self.context[id] = project
        self.flash(_(u'Project added.'), type=u'message')
        return self.redirect(self.url(self.context[id]))
Пример #2
0
    def add(self, **data):
        """Add a task inside the current project"""
        task = Task()
        task.creator = self.request.principal.title
        task.creation_date = datetime.datetime.now()
        task.modification_date = datetime.datetime.now()
        task.remaining = data['estimate']
        self.applyData(task, **data)

        title = data['title']
        suffix = 1
        id = normalize(title)
        while id in self.context:
            title += str(suffix)
            suffix += 1
            id = normalize(title)

        task.id = id
        self.context[id] = task
        self.flash(_(u'Task added.'), type=u'message')
        return self.redirect(self.url(self.context))