Added proposal withdrawal for students.
Patch by: Lennard de Rijk
Reviewed by: to-be-reviewed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/student_proposal/edit.html Wed Feb 25 20:11:22 2009 +0000
@@ -0,0 +1,22 @@
+{% extends "soc/models/edit.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+{% block delete_button %}
+{% if is_admin %}
+ {{ block.super }}
+{% endif %}
+<td>
+ <input type="submit" class="button" name="action" value="Withdraw"/>
+</td>
+{% endblock %}
--- a/app/soc/views/models/student_proposal.py Tue Feb 24 23:11:15 2009 +0000
+++ b/app/soc/views/models/student_proposal.py Wed Feb 25 20:11:22 2009 +0000
@@ -26,6 +26,7 @@
import time
from django import forms
+from django import http
from soc.logic import cleaning
from soc.logic import dicts
@@ -122,7 +123,7 @@
'link_id': forms.CharField(widget=forms.HiddenInput)
}
- # TODO(ljvderijk) students should be able to withdraw their proposals
+ new_params['edit_template'] = 'soc/student_proposal/edit.html'
params = dicts.merge(params, new_params)
@@ -173,6 +174,39 @@
@decorators.merge_params
@decorators.check_access
+ def edit(self, request, access_type,
+ page_name=None, params=None, seed=None, **kwargs):
+ """If the POST contains (action, Withdraw) the proposal in kwargs
+ will be marked as invalid.
+
+ For params see base.View.edit()
+ """
+
+ # check if request.POST contains action
+ post_dict = request.POST
+ if 'action' in post_dict and post_dict['action'] == 'Withdraw':
+ # withdraw this proposal
+ filter = {'scope_path': kwargs['scope_path'],
+ 'link_id': kwargs['link_id']}
+
+ proposal_logic = params['logic']
+ student_proposal_entity = proposal_logic.getForFields(filter, unique=True)
+
+ # update the entity mark it as invalid
+ proposal_logic.updateEntityProperties(student_proposal_entity,
+ {'status': 'invalid'})
+
+ # redirect to the program's homepage
+ redirect_url = redirects.getHomeRedirect(student_proposal_entity.program,
+ {'url_name': 'program'})
+
+ return http.HttpResponseRedirect(redirect_url)
+
+ return super(View, self).edit(request=request, access_type=access_type,
+ page_name=page_name, params=params, seed=seed, **kwargs)
+
+ @decorators.merge_params
+ @decorators.check_access
def listOrgs(self, request, access_type,
page_name=None, params=None, **kwargs):
"""Lists all organization which the given student can propose to.