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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-04 13:40:44 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090704134044-b5n1zaq6l325cc7a
Security (login/logout) done.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# Author: Nick Chadwick
19
19
 
20
 
import datetime
21
20
import ivle.database
22
21
from ivle.database import ProjectSet, Project, Subject, Semester, Offering
23
22
 
24
23
from ivle.webapp.base.rest import (XHTMLRESTView, named_operation,
25
24
                                   require_permission)
26
 
from ivle.webapp.errors import NotFound, BadRequest
 
25
from ivle.webapp.errors import NotFound
27
26
 
28
27
class ProjectSetRESTView(XHTMLRESTView):
29
28
    """Rest view for a projectset.
39
38
                 project.short_name)
40
39
 
41
40
    @named_operation('edit')
42
 
    def add_project(self, req, name, short_name, deadline, synopsis):
 
41
    def add_project(self, req, name, short_name, synopsis):
43
42
        """Add a Project to this ProjectSet"""
44
43
        new_project = Project()
45
44
        new_project.name = unicode(name)
46
45
        new_project.short_name = unicode(short_name)
47
46
        new_project.synopsis = unicode(synopsis)
48
 
        try:
49
 
            new_project.deadline = datetime.datetime.strptime(deadline, '%Y-%m-%d %H:%M:%S')
50
 
        except ValueError:
51
 
            raise BadRequest("deadline must be in YYYY-MM-DD HH:MM:ss")
52
47
        new_project.project_set = self.context
53
48
 
54
49
        req.store.add(new_project)
55
50
        req.store.flush()
56
51
    
57
52
        self.template = "templates/project_fragment.html"
58
 
        self.ctx['req'] = req
59
53
        self.ctx['project'] = new_project
 
54
        self.ctx['project_url'] = self._project_url(new_project)
60
55
 
61
56
        return {'success': True, 'projectset_id': self.context.id}
 
57
 
 
58
class ProjectRESTView(XHTMLRESTView):
 
59
    """Rest view for a project."""