Skip to content

Commit

Permalink
Added small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nemisis84 committed Nov 14, 2024
2 parents 6744106 + 850c0c2 commit 737c79a
Show file tree
Hide file tree
Showing 242 changed files with 5,579 additions and 1,858 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Force all files to use LF line endings
* text=auto
53 changes: 4 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,10 @@

<img src="./docs/splash.png"/>

## Documentation

- **[Technical Documentation](./docs/technical/README.md)**
- [Work Methodology](./docs/work-methodology.md)
- [Useful Commands](./docs/useful-commands.md)
- [Technologies used on Samf4 🤖](./docs/technical/Samf4Tech.md)
- [Project Specific Commands](./docs/docker-project-specific-commands.md)
- [Useful Docker aliases](./docs/docker-project-specific-commands.md)
- [🌐 API documentation](./docs/api-docs.md)

## Installation

We have a script that handles all installation for you. To run the script, a Github Personal Access Token (PAT) is required.
You can make one here https://github.com/settings/tokens/new. Tick scopes `repo`, `read:org` and `admin:public_key`),
then store the token somewhere safe (Github will never show it again).

Copy these commands (press button on the right-hand side of the block)
and run from the directory you would clone the project.

```sh
# Interactive
read -s -p "Github PAT token: " TOKEN ; X_INTERACTIVE=y /bin/bash -c "$(curl -fsSL https://$TOKEN@raw.githubusercontent.com/Samfundet/Samfundet4/master/{bash_utils.sh,install.sh})" && . ~/.bash_profile && cd Samfundet4; unset TOKEN; unset X_INTERACTIVE;
```
## Introduction

<details>
<summary>Non-interactive (show/hide)</summary>
Samfundet4 is the latest and greatest iteration of samfundet.no. It's built using Django and React.

```sh
# Non-interactive
read -s -p "Github PAT token: " TOKEN ; X_INTERACTIVE=n /bin/bash -c "$(curl -fsSL https://$TOKEN@raw.githubusercontent.com/Samfundet/Samfundet4/master/{bash_utils.sh,install.sh})" && . ~/.bash_profile && cd Samfundet4; unset TOKEN; unset X_INTERACTIVE;
```

<!--
cd ~/my-projects/test; rm -rf Samfundet4; read -s -p "Github PAT token: " TOKEN ; X_INTERACTIVE=y /bin/bash -c "$(curl -fsSL https://[email protected]/Samfundet/Samfundet4/master/{bash_utils.sh,install.sh})" && . ~/.bash_profile && cd Samfundet4; unset TOKEN; unset X_INTERACTIVE;
-->
</details>

<details>
<summary>Flags explained (show/hide)</summary>

> - X_INTERACTIVE (y/n): determines how many prompts you receive before performing an action.
> curl:
> - -f: fail fast
> - -s: silent, no progress-meter
> - -S: show error on fail
> - -L: follow redirect
</details>
## Documentation

<br>
<br>
<br>
Looking for install guides and technical documentation? Go to the [Documentation Overview](./docs/README.md)!
2 changes: 2 additions & 0 deletions backend/root/management/commands/seed_scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
recruitment_separate_position,
recruitment_interviewavailability,
recruitment_position_interviewers,
recruitment_sharedinterviewgroups,
)

# Insert seed scripts here (in order of priority)
Expand All @@ -50,6 +51,7 @@
('merch', merch.seed),
('recruitment', recruitment.seed),
('recruitment_position', recruitment_position.seed),
('recruitment_position_shared_interview', recruitment_sharedinterviewgroups.seed),
('recruitment_interviewavailability', recruitment_interviewavailability.seed),
('recruitment_separate_position', recruitment_separate_position.seed),
('recruitment_applications', recruitment_applications.seed),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import annotations

import random

from root.utils.samfundet_random import words

from samfundet.models.recruitment import Recruitment, RecruitmentPosition, RecruitmentPositionSharedInterviewGroup


def seed():
yield 0, 'recruitment_positions_shared_interview'
RecruitmentPositionSharedInterviewGroup.objects.all().delete()
yield 0, 'Deleted old recruitmentpositionsharedgroup'

recruitments = Recruitment.objects.all()
created_count = 0
for recruitment in recruitments:
for i in range(3):
RecruitmentPositionSharedInterviewGroup.objects.create(recruitment=recruitment, name_nb=f'{words(2)} {i}', name_en=f'{words(2)} {i}')
created_count += 1
shared_groups = list(RecruitmentPositionSharedInterviewGroup.objects.filter(recruitment=recruitment))
positions = random.sample(list(RecruitmentPosition.objects.filter(recruitment=recruitment)), 6)
for pos in positions:
pos.shared_interview_group = random.choice(shared_groups)
pos.save()

yield 100, f'Created {created_count} recruitment_position_shared_groups'
15 changes: 14 additions & 1 deletion backend/root/utils/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,15 @@
admin__samfundet_recruitmentapplication_delete = 'admin:samfundet_recruitmentapplication_delete'
admin__samfundet_recruitmentapplication_change = 'admin:samfundet_recruitmentapplication_change'
adminsamfundetrecruitmentapplication__objectId = ''
admin__samfundet_recruitmentpositionsharedinterviewgroup_permissions = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_permissions'
admin__samfundet_recruitmentpositionsharedinterviewgroup_permissions_manage_user = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_permissions_manage_user'
admin__samfundet_recruitmentpositionsharedinterviewgroup_permissions_manage_group = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_permissions_manage_group'
admin__samfundet_recruitmentpositionsharedinterviewgroup_changelist = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_changelist'
admin__samfundet_recruitmentpositionsharedinterviewgroup_add = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_add'
admin__samfundet_recruitmentpositionsharedinterviewgroup_history = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_history'
admin__samfundet_recruitmentpositionsharedinterviewgroup_delete = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_delete'
admin__samfundet_recruitmentpositionsharedinterviewgroup_change = 'admin:samfundet_recruitmentpositionsharedinterviewgroup_change'
adminsamfundetrecruitmentpositionsharedinterviewgroup__objectId = ''
admin__samfundet_organization_permissions = 'admin:samfundet_organization_permissions'
admin__samfundet_organization_permissions_manage_user = 'admin:samfundet_organization_permissions_manage_user'
admin__samfundet_organization_permissions_manage_group = 'admin:samfundet_organization_permissions_manage_group'
Expand Down Expand Up @@ -502,6 +511,8 @@
samfundet__saksdokument_detail = 'samfundet:saksdokument-detail'
samfundet__profile_list = 'samfundet:profile-list'
samfundet__profile_detail = 'samfundet:profile-detail'
samfundet__permissions_list = 'samfundet:permissions-list'
samfundet__permissions_detail = 'samfundet:permissions-detail'
samfundet__menu_list = 'samfundet:menu-list'
samfundet__menu_detail = 'samfundet:menu-detail'
samfundet__menu_items_list = 'samfundet:menu_items-list'
Expand Down Expand Up @@ -529,6 +540,7 @@
samfundet__merch_detail = 'samfundet:merch-detail'
samfundet__role_list = 'samfundet:role-list'
samfundet__role_detail = 'samfundet:role-detail'
samfundet__role_users = 'samfundet:role-users'
samfundet__recruitment_list = 'samfundet:recruitment-list'
samfundet__recruitment_detail = 'samfundet:recruitment-detail'
samfundet__recruitment_gangs = 'samfundet:recruitment-gangs'
Expand All @@ -553,7 +565,6 @@
samfundet__interview_list = 'samfundet:interview-list'
samfundet__interview_detail = 'samfundet:interview-detail'
samfundet__api_root = 'samfundet:api-root'
samfundet__api_root = 'samfundet:api-root'
samfundet__schema = 'samfundet:schema'
samfundet__swagger_ui = 'samfundet:swagger_ui'
samfundet__redoc = 'samfundet:redoc'
Expand All @@ -576,6 +587,7 @@
samfundet__recruitment_positions = 'samfundet:recruitment_positions'
samfundet__recruitment_show_unprocessed_applicants = 'samfundet:recruitment_show_unprocessed_applicants'
samfundet__recruitment_positions_gang_for_applicants = 'samfundet:recruitment_positions_gang_for_applicants'
samfundet__recruitment_shared_interviews = 'samfundet:recruitment_shared_interviews'
samfundet__recruitment_positions_gang_for_gangs = 'samfundet:recruitment_positions_gang_for_gangs'
samfundet__recruitment_set_interview = 'samfundet:recruitment_set_interview'
samfundet__recruitment_application_states_choices = 'samfundet:recruitment_application_states_choices'
Expand All @@ -586,6 +598,7 @@
samfundet__recruitment_user_priority_update = 'samfundet:recruitment_user_priority_update'
samfundet__recruitment_withdraw_application_recruiter = 'samfundet:recruitment_withdraw_application_recruiter'
samfundet__active_recruitment_positions = 'samfundet:active_recruitment_positions'
samfundet__rejected_applicants = 'samfundet:rejected_applicants/'
samfundet__applicants_without_interviews = 'samfundet:applicants_without_interviews'
samfundet__applicants_without_three_interview_criteria = 'samfundet:applicants_without_three_interview_criteria'
samfundet__recruitment_recruiter_dashboard = 'samfundet:recruitment_recruiter_dashboard'
Expand Down
23 changes: 23 additions & 0 deletions backend/samfundet/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
RecruitmentApplication,
RecruitmentSeparatePosition,
RecruitmentInterviewAvailability,
RecruitmentPositionSharedInterviewGroup,
)

# Common fields:
Expand Down Expand Up @@ -715,6 +716,28 @@ class RecruitmentApplicationAdmin(CustomBaseAdmin):
list_select_related = True


@admin.register(RecruitmentPositionSharedInterviewGroup)
class RecruitmentPositionSharedInterviewGroupAdmin(CustomBaseAdmin):
sortable_by = [
'recruitment',
'name_en',
'name_nb',
'__str__',
]
list_display = [
'recruitment',
'name_en',
'name_nb',
'__str__',
]
search_fields = [
'recruitment',
'name_en',
'name_nb',
'__str__',
]


@admin.register(Organization)
class OrganizationAdmin(CustomBaseAdmin):
sortable_by = ['id', 'name']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.1.1 on 2024-10-25 12:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('samfundet', '0007_alter_infobox_color_alter_infobox_image_and_more'),
]

operations = [
migrations.AddField(
model_name='event',
name='entrance_en',
field=models.CharField(blank=True, max_length=140, null=True),
),
migrations.AddField(
model_name='event',
name='entrance_nb',
field=models.CharField(blank=True, max_length=140, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.1.1 on 2024-10-29 17:39

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("samfundet", "0008_event_entrance_en_event_entrance_nb"),
]

operations = [
migrations.AddField(
model_name="recruitmentpositionsharedinterviewgroup",
name="name_en",
field=models.CharField(
default="hi",
help_text="Name of the recruitmentgroup (EN)",
max_length=100,
),
preserve_default=False,
),
migrations.AddField(
model_name="recruitmentpositionsharedinterviewgroup",
name="name_nb",
field=models.CharField(
default="hi",
help_text="Name of the recruitmentgroup (NB)",
max_length=100,
),
preserve_default=False,
),
]
18 changes: 18 additions & 0 deletions backend/samfundet/migrations/0010_recruitment_promo_media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.1 on 2024-10-31 19:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('samfundet', '0009_recruitmentpositionsharedinterviewgroup_name_en_and_more'),
]

operations = [
migrations.AddField(
model_name='recruitment',
name='promo_media',
field=models.CharField(blank=True, default=None, help_text='Youtube video id', max_length=11, null=True),
),
]
8 changes: 7 additions & 1 deletion backend/samfundet/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
description_long_en = models.TextField(blank=False, null=False)
description_short_nb = models.TextField(blank=False, null=False)
description_short_en = models.TextField(blank=False, null=False)
location = models.CharField(max_length=140, blank=False, null=False)
image = models.ForeignKey(Image, on_delete=models.PROTECT, blank=False, null=False)
host = models.CharField(max_length=140, blank=False, null=False)
editors = models.ManyToManyField(Gang, blank=True)

# ======================== #
# Venue/Entrance #
# ======================== #
location = models.CharField(max_length=140, blank=False, null=False) # AKA venue
entrance_nb = models.CharField(max_length=140, blank=True, null=True)
entrance_en = models.CharField(max_length=140, blank=True, null=True)

age_restriction = models.CharField(max_length=30, choices=EventAgeRestriction.choices, blank=False, null=False, default=None)
category = models.CharField(max_length=30, choices=EventCategory.choices, blank=False, null=False, default=EventCategory.OTHER)

Expand Down
9 changes: 8 additions & 1 deletion backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Recruitment(CustomBaseModel):
organization = models.ForeignKey(null=False, blank=False, to=Organization, on_delete=models.CASCADE, help_text='The organization that is recruiting')

max_applications = models.PositiveIntegerField(null=True, blank=True, verbose_name='Max applications per applicant')
promo_media = models.CharField(max_length=11, help_text='Youtube video id', null=True, default=None, blank=True)

def resolve_org(self, *, return_id: bool = False) -> Organization | int:
if return_id:
Expand Down Expand Up @@ -115,8 +116,11 @@ class RecruitmentPositionSharedInterviewGroup(CustomBaseModel):
blank=True,
)

name_nb = models.CharField(max_length=100, null=False, blank=False, help_text='Name of the recruitmentgroup (NB)')
name_en = models.CharField(max_length=100, null=False, blank=False, help_text='Name of the recruitmentgroup (EN)')

def __str__(self) -> str:
return f'{self.recruitment} Interviewgroup {self.id}'
return f'{self.recruitment} Interviewgroup {self.name_nb} {", ".join(list(self.positions.values_list("name_nb", flat=True)))}'


class RecruitmentPosition(CustomBaseModel):
Expand Down Expand Up @@ -261,6 +265,7 @@ class Interview(CustomBaseModel):
help_text='Room where the interview is held',
related_name='interviews',
)

interviewers = models.ManyToManyField(to='samfundet.User', help_text='Interviewers for this interview', blank=True, related_name='interviews')
notes = models.TextField(help_text='Notes for the interview', null=True, blank=True)

Expand All @@ -272,6 +277,7 @@ def resolve_gang(self, *, return_id: bool = False) -> Gang | int:


class RecruitmentApplication(CustomBaseModel):
# UUID so that applicants cannot see recruitment info with their own id number
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
application_text = models.TextField(help_text='Application text')
recruitment_position = models.ForeignKey(
Expand All @@ -283,6 +289,7 @@ class RecruitmentApplication(CustomBaseModel):

created_at = models.DateTimeField(null=True, blank=True, auto_now_add=True)

# Foreign Key because UKA and KSG have shared interviews (multiple applications share the same interview)
interview = models.ForeignKey(
Interview, on_delete=models.SET_NULL, null=True, blank=True, help_text='The interview for the application', related_name='applications'
)
Expand Down
4 changes: 2 additions & 2 deletions backend/samfundet/models/tests/test_recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_interview_group_autoadd_on_create(
assert fixture_recruitment_position2.shared_interview_group is None

# setup interview group
shared_group = RecruitmentPositionSharedInterviewGroup.objects.create(recruitment=fixture_recruitment)
shared_group = RecruitmentPositionSharedInterviewGroup.objects.create(recruitment=fixture_recruitment, name_en='name', name_nb='navn')
fixture_recruitment_position.shared_interview_group = shared_group
fixture_recruitment_position2.shared_interview_group = shared_group
fixture_recruitment_position.save()
Expand Down Expand Up @@ -288,7 +288,7 @@ def test_interview_group_autoset_on_set(
assert fixture_recruitment_application2.recruitment_position == fixture_recruitment_position2

# setup interview group
shared_group = RecruitmentPositionSharedInterviewGroup.objects.create(recruitment=fixture_recruitment)
shared_group = RecruitmentPositionSharedInterviewGroup.objects.create(recruitment=fixture_recruitment, name_en='name', name_nb='navn')
fixture_recruitment_position.shared_interview_group = shared_group
fixture_recruitment_position2.shared_interview_group = shared_group
fixture_recruitment_position.save()
Expand Down
Loading

0 comments on commit 737c79a

Please sign in to comment.