diff --git a/applications/forms/mentor.py b/applications/forms/mentor.py index 316df45e..e97a973e 100644 --- a/applications/forms/mentor.py +++ b/applications/forms/mentor.py @@ -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) diff --git a/applications/forms/volunteer.py b/applications/forms/volunteer.py index 409b731f..38c38017 100644 --- a/applications/forms/volunteer.py +++ b/applications/forms/volunteer.py @@ -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. *' ) + valid = forms.BooleanField( + required=False, + widget=forms.HiddenInput(), + initial=True, + ) + bootstrap_field_info = { "Información Personal": { "fields": [ diff --git a/applications/migrations/0049_auto_20240829_2026.py b/applications/migrations/0049_auto_20240829_2026.py new file mode 100644 index 00000000..91a34e2a --- /dev/null +++ b/applications/migrations/0049_auto_20240829_2026.py @@ -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')]), + ), + ] diff --git a/applications/migrations/0049_auto_20240830_1617.py b/applications/migrations/0049_auto_20240830_1617.py new file mode 100644 index 00000000..0efcf16f --- /dev/null +++ b/applications/migrations/0049_auto_20240830_1617.py @@ -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')]), + ), + ] diff --git a/applications/migrations/0050_auto_20240830_1119.py b/applications/migrations/0050_auto_20240830_1119.py new file mode 100644 index 00000000..f6f22d5d --- /dev/null +++ b/applications/migrations/0050_auto_20240830_1119.py @@ -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), + ), + ] diff --git a/applications/migrations/0051_merge_0049_auto_20240830_1617_0050_auto_20240830_1119.py b/applications/migrations/0051_merge_0049_auto_20240830_1617_0050_auto_20240830_1119.py new file mode 100644 index 00000000..85c6a1ab --- /dev/null +++ b/applications/migrations/0051_merge_0049_auto_20240830_1617_0050_auto_20240830_1119.py @@ -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 = [ + ] diff --git a/applications/models/mentor.py b/applications/models/mentor.py index 43527e6e..09594043 100644 --- a/applications/models/mentor.py +++ b/applications/models/mentor.py @@ -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) diff --git a/applications/models/volunteer.py b/applications/models/volunteer.py index 93361128..84c3fd51 100644 --- a/applications/models/volunteer.py +++ b/applications/models/volunteer.py @@ -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( diff --git a/organizers/tables.py b/organizers/tables.py index 2317ced6..3aa07fd4 100755 --- a/organizers/tables.py +++ b/organizers/tables.py @@ -174,7 +174,7 @@ class Meta: class VolunteerFilter(ApplicationFilter): class Meta: model = VolunteerApplication - fields = ['search', 'status'] + fields = ['search', 'status', 'valid'] class VolunteerListTable(tables.Table): @@ -182,11 +182,13 @@ class VolunteerListTable(tables.Table): "Detail ", 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' @@ -194,7 +196,7 @@ class Meta: class MentorFilter(ApplicationFilter): class Meta: model = MentorApplication - fields = ['search', 'status'] + fields = ['search', 'status', 'valid'] class MentorListTable(tables.Table): @@ -202,11 +204,13 @@ class MentorListTable(tables.Table): "Detail ", 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' diff --git a/organizers/templates/include/fieldAccent.html b/organizers/templates/include/fieldAccent.html new file mode 100644 index 00000000..452d6c8c --- /dev/null +++ b/organizers/templates/include/fieldAccent.html @@ -0,0 +1,16 @@ +{% if value %} +
{{ desc }} {% if showlength %} ({{ value | length}}) {% endif %}
+ {% if value == 'no' %} +
+ + {{ value }} + +
+ {% else %} +
+ + {{ value }} + +
+ {% endif %} +{% endif %} diff --git a/organizers/templates/other_application_detail.html b/organizers/templates/other_application_detail.html index dfefdad8..f1fe8fa5 100644 --- a/organizers/templates/other_application_detail.html +++ b/organizers/templates/other_application_detail.html @@ -35,7 +35,26 @@

Personal

{% 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 %} -
+
+
+

Validation

+
+
+ {% include 'include/fieldAccent.html' with desc="Valid?" value=app.valid|yesno %} +
+
+ {% csrf_token %} + + +
+
+

Volunteering

@@ -82,6 +101,24 @@

Sponsor

{% endif %} {% if app.user.is_mentor %}
+
+

Validation

+
+
+ {% include 'include/fieldAccent.html' with desc="Valid?" value=app.valid|yesno %} +
+
+ {% csrf_token %} + + +
+

Mentor

@@ -176,6 +213,12 @@

{{ comment.text }}

{% endif %} +
+
+ {% csrf_token %} + + +
{% endif %} diff --git a/organizers/views.py b/organizers/views.py index c878a225..2f351ece 100644 --- a/organizers/views.py +++ b/organizers/views.py @@ -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})) @@ -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}))