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

« back to all changes in this revision

Viewing changes to ivle/webapp/submit/__init__.py

  • Committer: David Coles
  • Date: 2010-07-28 10:45:53 UTC
  • mfrom: (1829 trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: coles.david@gmail.com-20100728104553-5z3nxt0l6kyfqfh5
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
            except ValueError:
86
86
                raise BadRequest('Project must be an integer.')
87
87
 
 
88
            # True, if the user has confirmed to submit late
 
89
            late = 'late' in data and data['late'] == "yes"
 
90
 
88
91
            project = req.store.find(Project, Project.id == projectid).one()
89
92
 
90
93
            # This view's offering will be the sole offering for which the
97
100
 
98
101
            try:
99
102
                ctx['submission'] = project.submit(self.context,
100
 
                                    unicode(self.path), revision, req.user)
101
 
            except (database.DeadlinePassed, database.SubmissionError), e:
 
103
                                    unicode(self.path), revision, req.user,
 
104
                                    late=late)
 
105
            except database.DeadlinePassed:
 
106
                # Show late submission page
 
107
                self.template = 'submit-late.html'
 
108
                ctx['project'] = project
 
109
            except database.SubmissionError, e:
102
110
                raise BadRequest(str(e) + ".")
103
 
 
104
 
            # The Subversion configuration needs to be updated, to grant
105
 
            # tutors and lecturers access to this submission. We have to 
106
 
            # commit early so usrmgt-server can see the new submission.
107
 
            req.store.commit()
108
 
 
109
 
            # Instruct usrmgt-server to rebuild the SVN group authz file.
110
 
            msg = {'rebuild_svn_group_config': {}}
111
 
            usrmgt = ivle.chat.chat(req.config['usrmgt']['host'],
112
 
                                    req.config['usrmgt']['port'],
113
 
                                    msg,
114
 
                                    req.config['usrmgt']['magic'],
115
 
                                    )
116
 
 
117
 
            if usrmgt.get('response') in (None, 'failure'):
118
 
                raise Exception("Failure creating repository: " + str(usrmgt))
119
 
 
120
 
            # Instruct usrmgt-server to rebuild the SVN user authz file.
121
 
            msg = {'rebuild_svn_config': {}}
122
 
            usrmgt = ivle.chat.chat(req.config['usrmgt']['host'],
123
 
                                    req.config['usrmgt']['port'],
124
 
                                    msg,
125
 
                                    req.config['usrmgt']['magic'],
126
 
                                    )
127
 
 
128
 
            if usrmgt.get('response') in (None, 'failure'):
129
 
                raise Exception("Failure creating repository: " + str(usrmgt))
130
 
 
131
 
            self.template = 'submitted.html'
132
 
            ctx['project'] = project
 
111
            else:
 
112
                # The Subversion configuration needs to be updated, to grant
 
113
                # tutors and lecturers access to this submission. We have to 
 
114
                # commit early so usrmgt-server can see the new submission.
 
115
                req.store.commit()
 
116
 
 
117
                # Instruct usrmgt-server to rebuild the SVN group authz file.
 
118
                msg = {'rebuild_svn_group_config': {}}
 
119
                usrmgt = ivle.chat.chat(req.config['usrmgt']['host'],
 
120
                                        req.config['usrmgt']['port'],
 
121
                                        msg,
 
122
                                        req.config['usrmgt']['magic'],
 
123
                                        )
 
124
 
 
125
                if usrmgt.get('response') in (None, 'failure'):
 
126
                    raise Exception("Failure creating repository: "
 
127
                                    + str(usrmgt))
 
128
 
 
129
                # Instruct usrmgt-server to rebuild the SVN user authz file.
 
130
                msg = {'rebuild_svn_config': {}}
 
131
                usrmgt = ivle.chat.chat(req.config['usrmgt']['host'],
 
132
                                        req.config['usrmgt']['port'],
 
133
                                        msg,
 
134
                                        req.config['usrmgt']['magic'],
 
135
                                        )
 
136
 
 
137
                if usrmgt.get('response') in (None, 'failure'):
 
138
                    raise Exception("Failure creating repository: "
 
139
                                    + str(usrmgt))
 
140
 
 
141
                self.template = 'submitted.html'
 
142
                ctx['project'] = project
133
143
 
134
144
        ctx['req'] = req
135
145
        ctx['principal'] = self.context
160
170
            Subject.short_name == self.path.split('/')[1],
161
171
            ).one()
162
172
 
 
173
    @property
 
174
    def fullpath(self):
 
175
        """Get the original path of this request, after the +submit."""
 
176
        return os.path.join('/users/', *self.subpath)
163
177
 
164
178
class GroupSubmitView(SubmitView):
165
179
    def get_repository_owner(self, store, name):
179
193
            Subject.short_name == namebits[0],
180
194
            Offering.semester_id == Semester.id,
181
195
            Semester.year == namebits[1],
182
 
            Semester.semester == namebits[2]).one()
 
196
            Semester.url_name == namebits[2]).one()
183
197
 
184
198
    def get_offering(self):
185
199
        return self.context.project_set.offering
186
200
 
 
201
    @property
 
202
    def fullpath(self):
 
203
        """Get the original path of this request, after the +submit."""
 
204
        return os.path.join('/groups/', *self.subpath)
 
205
 
187
206
 
188
207
class Plugin(ViewPlugin):
189
208
    views = [(ApplicationRoot, ('+submit', 'users'), UserSubmitView),