SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 787b985b authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add facility to easily update ProsFel status

parent a26ff00e
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,13 @@ PROSPECTIVE_FELLOW_STATUSES = (
(PROSPECTIVE_FELLOW_ACTIVE_IN_COLLEGE, 'Currently active in a College'),
(PROSPECTIVE_FELLOW_SCIPOST_EMERITUS, 'SciPost Emeritus'),
)
prospective_Fellow_statuses_dict = dict(PROSPECTIVE_FELLOW_STATUSES)
PROSPECTIVE_FELLOW_EVENT_DEFINED = 'defined'
PROSPECTIVE_FELLOW_EVENT_EMAILED = 'emailed'
PROSPECTIVE_FELLOW_EVENT_RESPONDED = 'responded'
PROSPECTIVE_FELLOW_EVENT_STATUSUPDATED = 'statusupdated'
PROSPECTIVE_FELLOW_EVENT_COMMENT = 'comment'
PROSPECTIVE_FELLOW_EVENT_DEACTIVATION = 'deactivation'
......@@ -40,6 +43,7 @@ PROSPECTIVE_FELLOW_EVENTS = (
(PROSPECTIVE_FELLOW_EVENT_DEFINED, 'Defined in database'),
(PROSPECTIVE_FELLOW_EVENT_EMAILED, 'Emailed with invitation'),
(PROSPECTIVE_FELLOW_EVENT_RESPONDED, 'Response received'),
(PROSPECTIVE_FELLOW_EVENT_STATUSUPDATED, 'Status updated'),
(PROSPECTIVE_FELLOW_EVENT_COMMENT, 'Comment'),
(PROSPECTIVE_FELLOW_EVENT_DEACTIVATION, 'Deactivation: not considered anymore'),
)
......@@ -227,6 +227,13 @@ class ProspectiveFellowForm(forms.ModelForm):
'discipline', 'expertises', 'webpage', 'status', 'contributor']
class ProspectiveFellowStatusForm(forms.ModelForm):
class Meta:
model = ProspectiveFellow
fields = ['status']
class ProspectiveFellowEventForm(forms.ModelForm):
class Meta:
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-07-03 10:08
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('colleges', '0005_auto_20180701_2110'),
]
operations = [
migrations.AlterField(
model_name='prospectivefellowevent',
name='event',
field=models.CharField(choices=[('defined', 'Defined in database'), ('emailed', 'Emailed with invitation'), ('responded', 'Response received'), ('statusupdated', 'Status updated'), ('comment', 'Comment'), ('deactivation', 'Deactivation: not considered anymore')], max_length=32),
),
]
......@@ -38,6 +38,13 @@
</ul>
</div>
<div class="col-md-5">
<h3>Update the status of this Prospective Fellow</h3>
<form class="d-block mt-2 mb-3" action="{% url 'colleges:prospective_Fellow_update_status' pk=prosfel.id %}" method="post">
{% csrf_token %}
{{ pfstatus_form|bootstrap }}
<input type="submit" name="submit" value="Update status" class="btn btn-outline-secondary">
</form>
<hr/>
<h3>Add an event for this Prospective Fellow</h3>
<form class="d-block mt-2 mb-3" action="{% url 'colleges:prospective_Fellow_event_create' pk=prosfel.id %}" method="post">
{% csrf_token %}
......
......@@ -59,6 +59,11 @@ urlpatterns = [
views.ProspectiveFellowUpdateView.as_view(),
name='prospective_Fellow_update'
),
url(
r'^prospectivefellows/(?P<pk>[0-9]+)/update_status/$',
views.ProspectiveFellowUpdateStatusView.as_view(),
name='prospective_Fellow_update_status'
),
url(
r'^prospectivefellows/(?P<pk>[0-9]+)/delete/$',
views.ProspectiveFellowDeleteView.as_view(),
......
......@@ -13,12 +13,15 @@ from django.views.generic.list import ListView
from submissions.models import Submission
from .constants import PROSPECTIVE_FELLOW_EVENT_EMAILED
from .constants import PROSPECTIVE_FELLOW_INVITED,\
prospective_Fellow_statuses_dict,\
PROSPECTIVE_FELLOW_EVENT_EMAILED, PROSPECTIVE_FELLOW_EVENT_STATUSUPDATED,\
PROSPECTIVE_FELLOW_EVENT_COMMENT
from .forms import FellowshipForm, FellowshipTerminateForm, FellowshipRemoveSubmissionForm,\
FellowshipAddSubmissionForm, AddFellowshipForm, SubmissionAddFellowshipForm,\
FellowshipRemoveProceedingsForm, FellowshipAddProceedingsForm, SubmissionAddVotingFellowForm,\
FellowVotingRemoveSubmissionForm,\
ProspectiveFellowForm, ProspectiveFellowEventForm
ProspectiveFellowForm, ProspectiveFellowStatusForm, ProspectiveFellowEventForm
from .models import Fellowship, ProspectiveFellow, ProspectiveFellowEvent
from scipost.constants import SCIPOST_SUBJECT_AREAS
......@@ -328,6 +331,27 @@ class ProspectiveFellowUpdateView(PermissionsMixin, UpdateView):
success_url = reverse_lazy('colleges:prospective_Fellows')
class ProspectiveFellowUpdateStatusView(PermissionsMixin, UpdateView):
"""
Formview to update the status of a Prospective Fellow.
"""
permission_required = 'scipost.can_manage_college_composition'
model = ProspectiveFellow
fields = ['status']
success_url = reverse_lazy('colleges:prospective_Fellows')
def form_valid(self, form):
event = ProspectiveFellowEvent(
prosfellow=self.object,
event=PROSPECTIVE_FELLOW_EVENT_STATUSUPDATED,
comments=('Status updated to %s'
% prospective_Fellow_statuses_dict[form.cleaned_data['status']]),
noted_on=timezone.now(),
noted_by=self.request.user.contributor)
event.save()
return super().form_valid(form)
class ProspectiveFellowDeleteView(PermissionsMixin, DeleteView):
"""
Delete a Prospective Fellow.
......@@ -359,6 +383,7 @@ class ProspectiveFellowListView(PermissionsMixin, ListView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['subject_areas'] = SCIPOST_SUBJECT_AREAS
context['pfstatus_form'] = ProspectiveFellowStatusForm()
context['pfevent_form'] = ProspectiveFellowEventForm()
return context
......@@ -383,6 +408,8 @@ class ProspectiveFellowInitialEmailView(PermissionsMixin, MailView):
noted_on=timezone.now(),
noted_by=self.request.user.contributor)
event.save()
self.object.status=PROSPECTIVE_FELLOW_INVITED
self.object.save()
return super().form_valid(form)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment