Skip to content

Commit

Permalink
Create application portal for group leaders (#780)
Browse files Browse the repository at this point in the history
* Listing group applications (WIP)

* Fixed displayed application names on internal portal

* Applicants' names are hyperlinks to individual applications

* Finished basic application look

* Admin of first choice group processes the application

* Fixed authentication error for applications page

* create view to move application to next group

* create application email text and upgrade views

* functionality to send email to person in group

* check if group exists before send mail

* check for superuser permissions

* empty commit

* delete unused file and remove superuser privelige

* create card for application

* add approve application page and separate into components

* add link to applications

* add comments for future work

* separate into own personalia box

* send email on successful new application

* create form to send email to applicant

* better styled and working form for writing email

* add timepicker

* translation and email header and back button

* translate internalportal

* add badge to internalportal and translations

* empty application list message and group choice list order

* edit email url to be full path

* create modal before sending to next group

* better links for error on sending application further

* change permission on applications view

* update locale file

* create translation for interview email

* email for deny and approve with translations

* more translations to emails. debugging

* finish application translations

* change translation in approve page

* remove newline on top of email, fix email copy bug and translate Subject

* delete weirdly created file I dont understand

* remove static/ from gitignore to add to new static files

* change to group names

---------

Co-authored-by: Njål Telstø <[email protected]>
Co-authored-by: zara <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2024
1 parent 1f88aee commit f1fefd3
Show file tree
Hide file tree
Showing 51 changed files with 1,748 additions and 80 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ profilepictures/
env/
venv/
.vscode/
static/
**/__pycache__
/static/

Expand Down
15 changes: 15 additions & 0 deletions applications/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ class Media:
@admin.register(Application)
class ApplicationAdmin(BaseApplicationAdmin):
inlines = [ApplicationGroupChoiceInline]
list_display = [
"name",
"email",
"groups",
]

def groups(self, obj):
return ", ".join(
[
group.name
for group in obj.group_choice.order_by(
"applicationgroupchoice__priority"
)
]
)
24 changes: 23 additions & 1 deletion applications/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from django.core.mail import send_mail
from django.forms import ModelForm, Textarea, TextInput
from django.template.loader import render_to_string
from django.urls import reverse

from committees.models import Committee

from .models import Application, ApplicationGroupChoice

Expand Down Expand Up @@ -74,4 +77,23 @@ def send_email(self):
[self.cleaned_data["email"]],
fail_silently=False,
)
pass

new_application_message = render_to_string(
"applications/new_application_email.txt",
{"applications_url": reverse("internalportal:applications")},
)
committee = Committee.objects.filter(
name=self.cleaned_data["group_choice"][0].name
).first()
if committee:
emails = [
getattr(committee.main_lead, "email", None),
getattr(committee.second_lead, "email", None),
]
send_mail(
"[Hackerspace NTNU] Ny søknad!",
new_application_message,
"Hackerspace NTNU",
emails,
fail_silently=False,
)
2 changes: 1 addition & 1 deletion applications/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-23 17:45+0200\n"
"POT-Creation-Date: 2023-11-27 17:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion applications/locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-23 17:45+0200\n"
"POT-Creation-Date: 2023-11-27 17:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.18 on 2023-11-27 00:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('applications', '0019_applicationgroup_open_for_applications'),
]

operations = [
migrations.AlterModelOptions(
name='applicationgroupchoice',
options={'ordering': ['priority']},
),
]
3 changes: 3 additions & 0 deletions applications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ class ApplicationGroupChoice(models.Model):
application = models.ForeignKey(Application, on_delete=models.CASCADE)
group = models.ForeignKey(ApplicationGroup, on_delete=models.CASCADE)
priority = models.PositiveIntegerField(null=True)

class Meta:
ordering = ["priority"]
22 changes: 22 additions & 0 deletions applications/templates/applications/new_application_email.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Hei,

Denne mailen blir sendt til deg fordi det har kommet en ny søknad til Hackerspace som har din gruppe på første valg.

Du finner aktive søknader her: {{ applications_url }}


Mvh,
Hackerspace NTNU

-----------------------------------


Hello,

This email is sent to you because there is a new applicant to Hackerspace with your group as highest priority.

You can find active applications here: {{ applications_url }}


Best regards,
Hackerspace NTNU
21 changes: 20 additions & 1 deletion authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.contrib.auth import logout
from django.contrib.auth import get_user_model, logout
from django.shortcuts import redirect
from django.urls import reverse
from django.views import View
Expand Down Expand Up @@ -75,3 +75,22 @@ def associate_by_email(backend, details, user=None, *args, **kwargs):
prison_user.save()

return {"user": alt_users[0], "is_new": False}


def get_user_by_stud_or_ntnu_email(email: str):
"""Check for the following cases:
1. Input email is the same as the user's email
2. User has a stud.ntnu.no email and input email is ntnu.no
3. User has a ntnu.no email and input email is stud.ntnu.no
"""
User = get_user_model()

for query_email in [
email,
email.split("@")[0] + "@stud.ntnu.no",
email.split("@")[0] + "@ntnu.no",
]:
user = User.objects.filter(email=query_email).first()
if user:
return user
2 changes: 1 addition & 1 deletion files/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-23 17:45+0200\n"
"POT-Creation-Date: 2023-11-27 17:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion files/locale/nb/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-23 17:45+0200\n"
"POT-Creation-Date: 2023-11-27 17:21+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@
"model": "applications.applicationgroup",
"pk": 8,
"fields": {
"name": "Spill",
"name": "Prosjekt: Spill",
"text_main": "Det har i mange år vært interesse for å utvikle spill på Hackerspace og vi har i like mange år holdt på med en spillutviklingsgruppe for å tilfredsstille folket.\r\nDen aktive spillutviklingsgruppen ble ferdig med sitt nyeste prosjekt våren 2022 og skal fortsette morroa med mer spillutvikling.\r\nMålet for prosjektet er å produsere et spill som skal delta på Norwegian game awards. Så gled dere til de gøye, sprø og kaotiske eventyrene som dere vil ha i dette prosjektet!",
"text_structure": "",
"text_workload": "",
Expand Down
25 changes: 25 additions & 0 deletions internalportal/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.db.models.fields import forms
from django.utils.translation import gettext_lazy as _

from news.forms import SplitDateTimeFieldCustom


class InterviewEmailForm(forms.Form):
location = forms.CharField(
label=_("Plassering"),
max_length=100,
required=True,
)
location_link = forms.CharField(
label=_("Lenke til plassering"),
max_length=100,
required=False,
)
start_time = SplitDateTimeFieldCustom(
label=_("Starttidspunkt"),
required=True,
)
end_time = SplitDateTimeFieldCustom(
label=_("Sluttidspunkt"),
required=False,
)
Loading

0 comments on commit f1fefd3

Please sign in to comment.