~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/projectservice.py

  • Committer: David Coles
  • Date: 2009-12-08 02:10:26 UTC
  • Revision ID: coles.david@gmail.com-20091208021026-3a27ecdzm49y39me
Configuration documentation - fixing a few references

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# Author: Nick Chadwick
19
19
 
 
20
import datetime
20
21
import ivle.database
21
22
from ivle.database import ProjectSet, Project, Subject, Semester, Offering
22
23
 
23
24
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
24
25
                                   require_permission)
25
 
from ivle.webapp.errors import NotFound
 
26
from ivle.webapp.errors import NotFound, BadRequest
26
27
 
27
28
class ProjectSetRESTView(XHTMLRESTView):
28
29
    """Rest view for a projectset.
51
52
                 project.short_name)
52
53
 
53
54
    @named_operation('edit')
54
 
    def add_project(self, req, name, short_name, synopsis):
 
55
    def add_project(self, req, name, short_name, deadline, synopsis):
55
56
        """Add a Project to this ProjectSet"""
56
57
        new_project = Project()
57
58
        new_project.name = unicode(name)
58
59
        new_project.short_name = unicode(short_name)
59
60
        new_project.synopsis = unicode(synopsis)
 
61
        try:
 
62
            new_project.deadline = datetime.datetime.strptime(deadline, '%Y-%m-%d %H:%M:%S')
 
63
        except ValueError:
 
64
            raise BadRequest("deadline must be in YYYY-MM-DD HH:MM:ss")
60
65
        new_project.project_set = self.context
61
66
 
62
67
        req.store.add(new_project)