~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: 2010-02-23 09:26:09 UTC
  • mfrom: (1606.2.1 expose-project-urls)
  • Revision ID: grantw@unimelb.edu.au-20100223092609-vtjbn09loljbhsf1
Expose Project.url in the creation form.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# Author: Nick Chadwick
19
19
 
20
20
import datetime
 
21
 
 
22
import formencode
 
23
import formencode.validators
 
24
 
21
25
import ivle.database
22
26
from ivle.database import ProjectSet, Project, Subject, Semester, Offering
23
27
 
40
44
                 project.short_name)
41
45
 
42
46
    @named_operation('edit')
43
 
    def add_project(self, req, name, short_name, deadline, synopsis):
 
47
    def add_project(self, req, name, short_name, deadline, synopsis, url):
44
48
        """Add a Project to this ProjectSet"""
45
49
        if not VALID_URL_NAME.match(short_name):
46
50
            raise BadRequest(
57
61
                "A project with that URL name already exists in this offering."
58
62
                )
59
63
 
 
64
        try:
 
65
            formencode.validators.URL().to_python(url)
 
66
        except formencode.Invalid, e:
 
67
            raise BadRequest(str(e))
 
68
 
60
69
        new_project = Project()
61
70
        new_project.name = unicode(name)
62
71
        new_project.short_name = unicode(short_name)
 
72
        new_project.url = unicode(url)
63
73
        new_project.synopsis = unicode(synopsis)
64
74
        try:
65
75
            new_project.deadline = datetime.datetime.strptime(deadline, '%Y-%m-%d %H:%M:%S')