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

Create application portal for group leaders #780

Merged
merged 40 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0180e88
Listing group applications (WIP)
njal3001 Oct 4, 2023
9b36c59
Fixed displayed application names on internal portal
Oct 4, 2023
566bf90
Applicants' names are hyperlinks to individual applications
Oct 18, 2023
dd067c0
Finished basic application look
Oct 18, 2023
60a1a0a
Admin of first choice group processes the application
Nov 1, 2023
fb3e6c4
Fixed authentication error for applications page
njal3001 Nov 8, 2023
83a73e7
create view to move application to next group
CJGutz Nov 8, 2023
7dec059
create application email text and upgrade views
CJGutz Nov 8, 2023
adbf643
functionality to send email to person in group
CJGutz Nov 8, 2023
13c1bfe
check if group exists before send mail
CJGutz Nov 13, 2023
0accdec
check for superuser permissions
CJGutz Nov 13, 2023
fe4a656
empty commit
CJGutz Nov 15, 2023
e3db43e
delete unused file and remove superuser privelige
CJGutz Nov 20, 2023
b3c0813
create card for application
CJGutz Nov 22, 2023
030e683
add approve application page and separate into components
CJGutz Nov 22, 2023
27c41d8
add link to applications
CJGutz Nov 22, 2023
89dfe52
add comments for future work
CJGutz Nov 23, 2023
a7e6631
separate into own personalia box
CJGutz Nov 23, 2023
221f579
send email on successful new application
CJGutz Nov 23, 2023
768810a
create form to send email to applicant
CJGutz Nov 26, 2023
68ac9fd
better styled and working form for writing email
CJGutz Nov 26, 2023
8f73bcf
add timepicker
CJGutz Nov 26, 2023
0dd276a
translation and email header and back button
CJGutz Nov 26, 2023
ef9e32f
translate internalportal
CJGutz Nov 26, 2023
729fa45
add badge to internalportal and translations
CJGutz Nov 26, 2023
15d6b62
empty application list message and group choice list order
CJGutz Nov 26, 2023
c2754f4
edit email url to be full path
CJGutz Nov 27, 2023
a8bbd49
create modal before sending to next group
CJGutz Nov 27, 2023
2a226fd
better links for error on sending application further
CJGutz Nov 27, 2023
5b2f997
change permission on applications view
CJGutz Nov 27, 2023
c9b9074
update locale file
CJGutz Nov 27, 2023
67e8c2e
create translation for interview email
CJGutz Nov 27, 2023
ddea232
email for deny and approve with translations
CJGutz Nov 27, 2023
df4e5cc
more translations to emails. debugging
CJGutz Nov 27, 2023
265d652
finish application translations
CJGutz Nov 27, 2023
f2df4b2
change translation in approve page
CJGutz Nov 27, 2023
91efa13
remove newline on top of email, fix email copy bug and translate Subject
CJGutz Nov 27, 2023
3a6b446
delete weirdly created file I dont understand
CJGutz Nov 28, 2023
1827f47
remove static/ from gitignore to add to new static files
CJGutz Nov 28, 2023
d25222b
change to group names
CJGutz Jan 17, 2024
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
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
Loading