Skip to content

Commit

Permalink
Merge pull request #116 from SELab-2/development
Browse files Browse the repository at this point in the history
🎉 First release
  • Loading branch information
EwoutV authored Mar 14, 2024
2 parents 7ce6f35 + d579f26 commit 37cbb36
Show file tree
Hide file tree
Showing 183 changed files with 11,208 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Default values
PUID=1000
PGID=1000
TZ=Europe/Brussels

# File directories
DATA_DIR="./data"
BACKEND_DIR="./backend"
FRONTEND_DIR="./frontend"
SSL_DIR="./data/nginx/ssl"

# Redis
REDIS_IP=192.168.90.10
REDIS_PORT=6379

# Django
DJANGO_SECRET_KEY="" # Set to a random string
DJANGO_DEBUG=True # Django debug mode
DJANGO_DOMAIN_NAME=localhost # Domain name for the Django server
DJANGO_CAS_URL_PREFIX="" # URL prefix for the CAS server. Should be empty for development
DJANGO_CAS_PORT=8080 # Port for the CAS server. Should be 8080 if DJANGO_DOMAIN_NAME is localhost
DJANGO_DB_ENGINE=django.db.backends.sqlite3 # Database engine
DJANGO_REDIS_HOST=${REDIS_IP} # Redis configuration
DJANGO_REDIS_PORT=${REDIS_PORT}
25 changes: 25 additions & 0 deletions .github/workflows/backend-linting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: backend-linting

on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
workflow_dispatch:

jobs:
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r ./backend/requirements.txt
- name: Execute linting checks
run: flake8 --config ./backend/.flake8 ./backend
27 changes: 27 additions & 0 deletions .github/workflows/backend-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: backend-tests

on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
workflow_dispatch:

jobs:
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r ./backend/requirements.txt
- name: Compile translations
run: django-admin compilemessages
- name: Execute tests
run: cd backend; python manage.py test
23 changes: 23 additions & 0 deletions .github/workflows/deployement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy
on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT }}
script: |
cd UGent-7
docker-compose -f production.yml down
${{ secrets.PULL_SCRIPT }}
docker-compose -f production.yml build --no-cache
docker-compose -f production.yml up -d
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.tool-versions
.env
.venv
.idea
.vscode
data/*
data/nginx/ssl/*
data/postres*
data/redis/*
backend/data/production/*

/node_modules
backend/staticfiles/*

!data/nginx/ssl/.gitkeep
36 changes: 36 additions & 0 deletions .prod.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Default values
PUID=1000
PGID=1000
TZ=Europe/Brussels

# File directories
DATA_DIR="./data"
BACKEND_DIR="./backend"
FRONTEND_DIR="./frontend"
SSL_DIR=""

# Postgress DB
POSTGRES_IP=192.168.90.9
POSTGRES_PORT=5432
POSTGRES_DB=selab
POSTGRES_USER=selab_user
POSTGRES_PASSWORD="" # Set to desired password

# Redis
REDIS_IP=192.168.90.10
REDIS_PORT=6379

# Django
DJANGO_SECRET_KEY="" # Set to a random string
DJANGO_DEBUG=False # Django debug mode
DJANGO_DOMAIN_NAME="" # Domain name for the Django server
DJANGO_CAS_URL_PREFIX="" # URL prefix for the CAS server
DJANGO_CAS_PORT="" # Port for the CAS server
DJANGO_DB_ENGINE=django.db.backends.postgresql # Database engine configuration
DJANGO_DB_NAME=${POSTGRES_DB}
DJANGO_DB_USER=${POSTGRES_USER}
DJANGO_DB_PASSWORD=${POSTGRES_PASSWORD}
DJANGO_DB_HOST=${POSTGRES_IP}
DJANGO_DB_PORT=${POSTGRES_PORT}
DJANGO_REDIS_HOST=${REDIS_IP} # Redis configuration
DJANGO_REDIS_PORT=${REDIS_PORT}
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# UGent-7
# Ypovoli

![backend linting](https://github.com/SELab-2/UGent-7/actions/workflows/backend-linting.yaml/badge.svg)
![backend tests](https://github.com/SELab-2/UGent-7/actions/workflows/backend-tests.yaml/badge.svg)

This application was developed within the framework of the course "Software Engineering Lab 2" within the Computer Science program at Ghent University.

## Documentation

See our wiki at [https://github.com/SELab-2/UGent-7/wiki](https://github.com/SELab-2/UGent-7/wiki) for more detailed information on the project's architecture.
Binary file added backend/.coverage
Binary file not shown.
15 changes: 15 additions & 0 deletions backend/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]

# Ignore unused imports
ignore = F401

max-line-length = 125

max-complexity = 10

exclude = .git,
__pycache__,
.venv,
venv,
migrations

5 changes: 5 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.venv
.idea
db.sqlite3
__pycache__
*.mo
13 changes: 13 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.11.4

RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip

WORKDIR /code

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY requirements.txt /code/
RUN pip install -r requirements.txt

COPY . /code/
16 changes: 16 additions & 0 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11.4

RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip

WORKDIR /code

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY requirements.txt /code/
RUN pip install -r requirements.txt

COPY . /code/

RUN ./setup.sh

15 changes: 15 additions & 0 deletions backend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.11.4

RUN apt update && apt install -y gettext libgettextpo-dev && pip install --upgrade pip

WORKDIR /code

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

RUN ./setup.sh
15 changes: 15 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Prerequisites

- python 3.11.8

__Django doesn't support python 3.12__

# Install instructions

- Create a virtual environment `python -m venv .venv` (make sure to use the right python version)

- Activate the virtual environment `source .venv/bin/activate`

- Run `setup.sh`

- Run the server `python manage.py runsslserver localhost:8080`
Empty file added backend/api/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions backend/api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "api"

def ready(self):
from authentication.signals import user_created
from api.signals import user_creation

user_created.connect(user_creation)
10 changes: 10 additions & 0 deletions backend/api/fixtures/assistants.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- model: api.assistant
pk: '235'
fields:
courses:
- 1
- model: api.assistant
pk: '236'
fields:
courses:
- 2
22 changes: 22 additions & 0 deletions backend/api/fixtures/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- model: api.extracheck
pk: 1
fields:
project: 123456
run_script: 'scripts/run.sh'

- model: api.fileextension
pk: 1
fields:
extension: 'class'
- model: api.fileextension
pk: 2
fields:
extension: 'png'
- model: api.fileextension
pk: 3
fields:
extension: 'java'
- model: api.fileextension
pk: 4
fields:
extension: 'py'
21 changes: 21 additions & 0 deletions backend/api/fixtures/courses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- model: api.course
pk: 1
fields:
name: Math
academic_startyear: 2023
description: Math course
parent_course: null
- model: api.course
pk: 2
fields:
name: Sel2
academic_startyear: 2023
description: Software course
parent_course: 3
- model: api.course
pk: 3
fields:
name: Sel1
academic_startyear: 2022
description: Software course
parent_course: null
20 changes: 20 additions & 0 deletions backend/api/fixtures/groups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- model: api.group
pk: 1
fields:
project: 123456
score: 7
students:
- '1'
- '2'
- model: api.group
pk: 3
fields:
project: 123456
score: 8
students: []
- model: api.group
pk: 2
fields:
project: 1
score: 8
students: []
24 changes: 24 additions & 0 deletions backend/api/fixtures/projects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- model: api.project
pk: 123456
fields:
name: sel2
description: make a project
visible: true
archived: false
start_date: 2024-02-26 00:00:00+00:00
deadline: 2024-02-27 00:00:00+00:00
group_size: 3
max_score: 20
course: 2
- model: api.project
pk: 1
fields:
name: sel3
description: make a project
visible: true
archived: false
start_date: 2024-02-26 00:00:00+00:00
deadline: 2024-02-27 00:00:00+00:00
group_size: 3
max_score: 20
course: 1
11 changes: 11 additions & 0 deletions backend/api/fixtures/students.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- model: api.student
pk: '1'
fields:
student_id: null
courses:
- 1
- model: api.student
pk: '2'
fields:
student_id: null
courses: []
Loading

0 comments on commit 37cbb36

Please sign in to comment.