Skip to content

Commit

Permalink
Merge branch 'master' into robin/role-page
Browse files Browse the repository at this point in the history
  • Loading branch information
robines committed Nov 16, 2024
2 parents ce7f02c + c645157 commit 34c29c1
Show file tree
Hide file tree
Showing 17 changed files with 292 additions and 169 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"yzhang.markdown-all-in-one",
"stylelint.vscode-stylelint",
"ms-python.mypy-type-checker",
"visualstudioexptteam.vscodeintellicode"
"visualstudioexptteam.vscodeintellicode",
"ms-vscode-remote.vscode-remote-extensionpack"
]
}
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,54 @@

Samfundet4 is the latest and greatest iteration of samfundet.no. It's built using Django and React.

## Documentation

Looking for install guides and technical documentation? Go to the [Documentation Overview](./docs/README.md)!
## Documentation Overview

> [!TIP]
> If you're new, start by going through the [Introduction to Samfundet4](./docs/introduction.md) guide.
### Frontend

- [Creating react components (conventions)](./docs/technical/frontend/components.md)
- [Forms and schemas](./docs/technical/frontend/forms.md)
- [*Deprecated: SamfForm*](./docs/technical/frontend/samfform.md)
- [Cypress Setup Documentation](./docs/technical/frontend/cypress.md)
- [Data fetching and State management](./docs/technical/frontend/data-fetching.md)

### Backend

- [🌐 API documentation](./docs/api-docs.md)
- [Billig (payment system)](./docs/technical/backend/billig.md)
- [Seed scripts](./docs/technical/backend/seed.md)
- [Role system](./docs/technical/backend/rolesystem.md)

### Other

- [Automatic Interview Scheduling](./docs/intervew-scheduling.md)

### Workflow

- [Work Methodology](./docs/work-methodology.md)
- How to contribute to the project
- [Useful Commands](./docs/useful-commands.md)
- [Useful Docker aliases](./docs/docker-project-specific-commands.md)
- [Common error messages](./docs/common-errors.md)

### Pipelines & Deployment

- [Pipeline (mypy, Biome, tsc, ...)](./docs/technical/pipeline.md)

### Install

- Linux: [Docker](./docs/install/linux-docker.md)[Native](./docs/install/linux-native.md)
- MacOS: [Docker](./docs/install/mac-docker.md)[Native](./docs/install/mac-native.md)
- Windows: [Docker](./docs/install/windows-docker.md)[WSL](./docs/install/windows-wsl.md)
- [Install script](./docs/install/install-script.md)
- [Post-install instructions](./docs/install/post-install.md)

### Editor configuration

* [JetBrains (WebStorm, PyCharm, etc...)](./docs/editors/jetbrains.md)
* [VS Code](./docs/editors/vscode.md)
* [Vim/Neovim](./docs/editors/vim.md)
* [Emacs](./docs/editors/emacs.md)
2 changes: 2 additions & 0 deletions backend/root/utils/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@
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 Down Expand Up @@ -608,5 +609,6 @@
samfundet__recruitment_availability = 'samfundet:recruitment_availability'
samfundet__feedback = 'samfundet:feedback'
samfundet__purchase_feedback = 'samfundet:purchase_feedback'
samfundet__gang_application_stats = 'samfundet:gang-application-stats'
static__path = ''
media__path = ''
1 change: 1 addition & 0 deletions backend/samfundet/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@
path('recruitment/<int:id>/availability/', views.RecruitmentAvailabilityView.as_view(), name='recruitment_availability'),
path('feedback/', views.UserFeedbackView.as_view(), name='feedback'),
path('purchase-feedback/', views.PurchaseFeedbackView.as_view(), name='purchase_feedback'),
path('recruitment/<int:recruitment_id>/gang/<int:gang_id>/stats/', views.GangApplicationCountView.as_view(), name='gang-application-stats'),
]
9 changes: 9 additions & 0 deletions backend/samfundet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def event_query(*, query: QueryDict, events: QuerySet[Event] = None) -> QuerySet
return events


def user_query(*, query: QueryDict, users: QuerySet[User] = None) -> QuerySet[User]:
if not users:
users = User.objects.all()
search = query.get('search', None)
if search:
users = users.filter(Q(username__icontains=search) | Q(first_name__icontains=search) | Q(last_name__icontains=search))
return users


def generate_timeslots(start_time: datetime.time, end_time: datetime.time, interval_minutes: int) -> list[str]:
# Convert from datetime.time objects to datetime.datetime
start_datetime = datetime.datetime.combine(datetime.datetime.today(), start_time)
Expand Down
25 changes: 24 additions & 1 deletion backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
REQUESTED_IMPERSONATE_USER,
)

from .utils import event_query, generate_timeslots, get_occupied_timeslots_from_request
from .utils import user_query, event_query, generate_timeslots, get_occupied_timeslots_from_request
from .homepage import homepage
from .models.role import Role, UserOrgRole, UserGangRole, UserGangSectionRole
from .serializers import (
Expand Down Expand Up @@ -137,6 +137,7 @@
Recruitment,
InterviewRoom,
OccupiedTimeslot,
RecruitmentGangStat,
RecruitmentPosition,
RecruitmentStatistics,
RecruitmentApplication,
Expand Down Expand Up @@ -492,6 +493,10 @@ class AllUsersView(ListAPIView):
serializer_class = UserSerializer
queryset = User.objects.all()

def get(self, request: Request) -> Response:
users = user_query(query=request.query_params)
return Response(data=UserSerializer(users, many=True).data)


class ImpersonateView(APIView):
permission_classes = [IsAuthenticated] # TODO: Permission check.
Expand Down Expand Up @@ -1362,3 +1367,21 @@ def post(self, request: Request) -> Response:
form=purchase_model,
)
return Response(status=status.HTTP_201_CREATED, data={'message': 'Feedback submitted successfully!'})


class GangApplicationCountView(APIView):
permission_classes = [IsAuthenticated]

def get(self, request: Request, recruitment_id: int, gang_id: int) -> Response:
# Get total applications from RecruitmentGangStat
gang_stat = get_object_or_404(RecruitmentGangStat, gang_id=gang_id, recruitment_stats__recruitment_id=recruitment_id)

return Response(
{
'total_applications': gang_stat.application_count,
'total_applicants': gang_stat.applicant_count,
'average_priority': gang_stat.average_priority,
'total_accepted': gang_stat.total_accepted,
'total_rejected': gang_stat.total_rejected,
}
)
52 changes: 0 additions & 52 deletions docs/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/install/windows-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
> [!WARNING]
> This guide is not complete! Feel free to submit a PR to improve it :-)
> [!NOTE]
> We do not recommend running the project this way. This is essentially running nested virtualization, which will lead
> to poor performance. Prefer running [directly in WSL](./windows-wsl.md).
# Installing on Windows (Docker in WSL)

## Install WSL
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Components/RejectionMail/RejectionMail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { t } from 'i18next';
import { useState } from 'react';
import { useParams } from 'react-router-dom';
import { toast } from 'react-toastify';
import { postRejectionMail } from '~/api';
//import { postRejectionMail } from '~/api';
import { KEY } from '~/i18n/constants';
import { Button } from '../Button';
import { InputField } from '../InputField';
Expand All @@ -15,7 +15,7 @@ export function RejectionMail() {

function handleSubmit() {
if (recruitmentId) {
postRejectionMail(recruitmentId, { subject, text });
//postRejectionMail(recruitmentId, { subject, text });
toast.success(t(KEY.common_save_successful));
} else {
toast.error(t(KEY.common_something_went_wrong));
Expand Down
Loading

0 comments on commit 34c29c1

Please sign in to comment.