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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

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)