Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate volunteers (#334) #337

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions applications/forms/mentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class MentorApplicationForm(_BaseApplicationForm):

online = common_online()

valid = forms.BooleanField(
required=False,
widget=forms.HiddenInput(),
initial=True,
)

def clean_resume(self):
resume = self.cleaned_data["resume"]
size = getattr(resume, "_size", 0)
Expand Down
6 changes: 6 additions & 0 deletions applications/forms/volunteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class VolunteerApplicationForm(_BaseApplicationForm):
label='Autorizo a "HackersAtUpc" a utilizar mi información sobre alergias e intolerancias alimentarias únicamente para gestionar el servicio de catering.<span style="color: red; font-weight: bold;"> *</span>'
)

valid = forms.BooleanField(
required=False,
widget=forms.HiddenInput(),
initial=True,
)

bootstrap_field_info = {
"Información Personal": {
"fields": [
Expand Down
24 changes: 24 additions & 0 deletions applications/migrations/0049_auto_20240829_2026.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.23 on 2024-08-29 18:26

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('applications', '0048_alter_volunteerapplication_night_shifts'),
]

operations = [
migrations.AddField(
model_name='volunteerapplication',
name='disregarded',
field=models.IntegerField(choices=[(0, 'No'), (1, 'Sí')], default=0),
),
migrations.AlterField(
model_name='hackerapplication',
name='reimb_amount',
field=models.FloatField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0, 'Negative? Really? Please put a positive value'), django.core.validators.MaxValueValidator(200.0, 'Do not exceed the maximum amount of 200')]),
),
]
29 changes: 29 additions & 0 deletions applications/migrations/0049_auto_20240830_1617.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.23 on 2024-08-30 14:17

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('applications', '0048_alter_volunteerapplication_night_shifts'),
]

operations = [
migrations.AddField(
model_name='mentorapplication',
name='valid',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='volunteerapplication',
name='valid',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='hackerapplication',
name='reimb_amount',
field=models.FloatField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0, 'Negative? Really? Please put a positive value'), django.core.validators.MaxValueValidator(200.0, 'Do not exceed the maximum amount of 200')]),
),
]
22 changes: 22 additions & 0 deletions applications/migrations/0050_auto_20240830_1119.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.23 on 2024-08-30 09:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('applications', '0049_auto_20240829_2026'),
]

operations = [
migrations.RemoveField(
model_name='volunteerapplication',
name='disregarded',
),
migrations.AddField(
model_name='volunteerapplication',
name='valid',
field=models.BooleanField(default=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.23 on 2024-09-05 08:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('applications', '0049_auto_20240830_1617'),
('applications', '0050_auto_20240830_1119'),
]

operations = [
]
1 change: 1 addition & 0 deletions applications/models/mentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MentorApplication(
blank=True,
validators=[validate_file_extension],
)
valid = models.BooleanField(default=False)

def can_be_edit(self, app_type="M"):
return self.status in [APP_PENDING, APP_DUBIOUS] and not utils.is_app_closed(app_type)
1 change: 1 addition & 0 deletions applications/models/volunteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class VolunteerApplication(BaseApplication):
night_shifts = MultiSelectField(choices=NIGHT_SHIFT_ES, default='No')
hobbies = models.CharField(max_length=150, null=False)
volunteer_motivation = models.CharField(max_length=500)
valid = models.BooleanField(default=True)

def can_be_edit(self, app_type="V"):
return self.status in [APP_PENDING, APP_DUBIOUS] and not utils.is_app_closed(
Expand Down
12 changes: 8 additions & 4 deletions organizers/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,39 +174,43 @@ class Meta:
class VolunteerFilter(ApplicationFilter):
class Meta:
model = VolunteerApplication
fields = ['search', 'status']
fields = ['search', 'status', 'valid']


class VolunteerListTable(tables.Table):
detail = tables.TemplateColumn(
"<a href='{% url 'volunteer_detail' record.uuid %}'>Detail</a> ",
verbose_name='Actions', orderable=False)

valid = tables.BooleanColumn(accessor='valid', verbose_name='Valid')

class Meta:
model = VolunteerApplication
attrs = {'class': 'table table-hover'}
template = 'django_tables2/bootstrap-responsive.html'
fields = ['user.name', 'user.email', 'status']
fields = ['user.name', 'user.email', 'status', 'valid']
empty_text = 'No Volunteer Application available'
order_by = '-submission_date'


class MentorFilter(ApplicationFilter):
class Meta:
model = MentorApplication
fields = ['search', 'status']
fields = ['search', 'status', 'valid']


class MentorListTable(tables.Table):
detail = tables.TemplateColumn(
"<a href='{% url 'mentor_detail' record.uuid %}'>Detail</a> ",
verbose_name='Actions', orderable=False)

valid = tables.BooleanColumn(accessor='valid', verbose_name='Valid')

class Meta:
model = MentorApplication
attrs = {'class': 'table table-hover'}
template = 'django_tables2/bootstrap-responsive.html'
fields = ['user.name', 'user.email', 'status']
fields = ['user.name', 'user.email', 'status', 'valid']
empty_text = 'No Mentor Application available'
order_by = '-submission_date'

Expand Down
16 changes: 16 additions & 0 deletions organizers/templates/include/fieldAccent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if value %}
<dt>{{ desc }} {% if showlength %} ({{ value | length}}) {% endif %}</dt>
{% if value == 'no' %}
<dd>
<span style="color: darkred; text-transform: uppercase; font-weight: bolder">
{{ value }}
</span>
</dd>
{% else %}
<dd>
<span style="color: darkgreen; text-transform: uppercase; font-weight: bolder">
{{ value }}
</span>
</dd>
{% endif %}
{% endif %}
45 changes: 44 additions & 1 deletion organizers/templates/other_application_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,26 @@ <h3>Personal</h3>
{% include 'include/field.html' with desc='Gender' value=app.get_gender_display %}
{% include 'include/field.html' with desc='Other gender' value=app.other_gender %}
{% include 'include/field.html' with desc='In BCN Apr-May' value=app.lennyface|yesno %}
<hr>
<hr>
<dt>
<h3>Validation</h3>
</dt>
<dd></dd>
{% include 'include/fieldAccent.html' with desc="Valid?" value=app.valid|yesno %}
<br>
<form action="" method="post">
{% csrf_token %}
<input type="hidden" name="app_id" value="{{ app.pk }}"/>
<button name="change_valid" class="btn btn-default btn-block" value="valid">
{% if app.valid %}
Invalidate
{% else %}
Validate
{% endif %}
</button>
</form>
<br>
<hr>
<dt>
<h3>Volunteering</h3>
</dt>
Expand Down Expand Up @@ -82,6 +101,24 @@ <h3>Sponsor</h3>
{% endif %}
{% if app.user.is_mentor %}
<hr>
<dt>
<h3>Validation</h3>
</dt>
<dd></dd>
{% include 'include/fieldAccent.html' with desc="Valid?" value=app.valid|yesno %}
<br>
<form action="" method="post">
{% csrf_token %}
<input type="hidden" name="app_id" value="{{ app.pk }}"/>
<button name="change_valid" class="btn btn-default btn-block" value="valid">
{% if app.valid %}
Invalidate
{% else %}
Validate
{% endif %}
</button>
</form>
<br>
<dt>
<h3>Mentor</h3>
</dt>
Expand Down Expand Up @@ -176,6 +213,12 @@ <h4>{{ comment.text }}</h4>
<button name="cancel_invite" class="btn btn-danger btn-block" value="cancel_invite">Move back to review</button>
{% endif %}
</form>
<br>
<form action="" method="post">
{% csrf_token %}
<input type="hidden" name="app_id" value="{{ app.pk }}"/>
<button name="reject" class="btn btn-danger btn-block" value="reject">Reject</button>
</form>
</div>

{% endif %}
Expand Down
15 changes: 13 additions & 2 deletions organizers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,19 @@ def post(self, request, *args, **kwargs):
if m:
m.send()
messages.success(request, 'Volunteer invited!')
elif request.POST.get('reject') and request.user.is_organizer:
application.reject()
application.save()
elif request.POST.get('cancel_invite') and request.user.is_organizer:
application.move_to_pending()
messages.success(request, 'Volunteer invite canceled')
elif request.POST.get('add_comment'):
add_comment(application, request.user, comment_text)
messages.success(request, 'Comment added')
elif request.POST.get('change_valid') and request.user.is_organizer:
application.valid = not application.valid
application.save()
messages.success(request, 'Volunteer valid status changed')

return HttpResponseRedirect(reverse('volunteer_detail', kwargs={'id': application.uuid_str}))

Expand Down Expand Up @@ -633,13 +640,17 @@ def post(self, request, *args, **kwargs):
m = emails.create_invite_email(application, self.request)
if m:
m.send()
messages.success(request, 'sponsor invited!')
messages.success(request, 'Mentor invited!')
elif request.POST.get('cancel_invite') and request.user.is_organizer:
application.move_to_pending()
messages.success(request, 'Sponsor invite canceled')
messages.success(request, 'Mentor invite canceled')
elif request.POST.get('add_comment'):
add_comment(application, request.user, comment_text)
messages.success(request, 'comment added')
elif request.POST.get('change_valid') and request.user.is_organizer:
application.valid = not application.valid
application.save()
messages.success(request, 'Mentor valid status changed')

return HttpResponseRedirect(reverse('mentor_detail', kwargs={'id': application.uuid_str}))

Expand Down