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

Update django and dependencies #125

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install

- name: Copy settings.py
run: |
cp course-management/course/settings.py.example course-management/course/settings.py

- name: Run migrations
run: |
poetry run python course-management/manage.py migrate

- name: Run tests
run: |
poetry run python course-management/manage.py test
2 changes: 1 addition & 1 deletion course-management/course/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from course.models.course import Course
from course.models.schedule import Schedule, DateSlot, WeeklySlot
Expand Down
2 changes: 1 addition & 1 deletion course-management/course/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import course, schedule, subject, news
from course.models import course, schedule, subject, news
2 changes: 1 addition & 1 deletion course-management/course/models/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from guardian.models import UserObjectPermission

from . import subject
from course.models import subject

from user.models import UserInformation, get_user_information

Expand Down
2 changes: 1 addition & 1 deletion course-management/course/models/schedule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from . import course

Expand Down
2 changes: 1 addition & 1 deletion course-management/course/util/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.urls import reverse
from django.shortcuts import redirect

Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.urls import reverse
from django.http import HttpRequest
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.http import require_POST
from guardian.shortcuts import assign_perm
from guardian.shortcuts import remove_perm
Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/enroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.http import HttpRequest, HttpResponseForbidden
from django.views.decorators.http import require_POST
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from course.models.course import Course

Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from course.models import news
from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _


def index(request):
Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.decorators import login_required, permission_required
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.http import HttpRequest

from course.models import news
Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.decorators import login_required, permission_required
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from course.models import subject
from course.forms import SubjectForm
Expand Down
2 changes: 1 addition & 1 deletion course-management/course/views/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from course.models.course import Course
from course import forms
Expand Down
22 changes: 17 additions & 5 deletions course-management/manage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#!/usr/bin/env python3
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "course.settings")

from django.core.management import execute_from_command_line

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'course.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion course-management/user/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import forms
from django.core.validators import RegexValidator, validate_email
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.forms import UserCreationForm

from user.models import UserInformation, User
Expand Down
2 changes: 1 addition & 1 deletion course-management/user/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError
from markdown import markdown
from django.views.decorators.debug import sensitive_variables
Expand Down
2 changes: 1 addition & 1 deletion course-management/user/views/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.http import HttpRequest
from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_protect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from user.forms import ContactForm
from util.error.reporting import db_error
Expand Down
2 changes: 1 addition & 1 deletion course-management/user/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.urls import reverse
from django.shortcuts import render, redirect
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables

from user.forms import UserInformationForm, UserForm
Expand Down
2 changes: 1 addition & 1 deletion course-management/user/views/user.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.debug import sensitive_post_parameters

from user.forms import UserForm, UserInformationForm, UserEditForm, PrivacyAgreementForm
Expand Down
2 changes: 1 addition & 1 deletion course-management/user/views/verify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.shortcuts import redirect, render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _

from django.core.exceptions import ObjectDoesNotExist
from django.views.decorators.http import require_GET
Expand Down
4 changes: 2 additions & 2 deletions course-management/util/html_clean.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bleach


DESCR_ALLOWED_TAGS = bleach.ALLOWED_TAGS + ['h2', 'h3', 'h4', 'h5', 'h6', 'br', 'p', 'img']
USER_DESCR_ALLOWED_TAGS = bleach.ALLOWED_TAGS + ['h2', 'h3', 'h4', 'h5', 'h6', 'br', 'p']
DESCR_ALLOWED_TAGS = list(bleach.ALLOWED_TAGS) + ['h2', 'h3', 'h4', 'h5', 'h6', 'br', 'p', 'img']
USER_DESCR_ALLOWED_TAGS = list(bleach.ALLOWED_TAGS) + ['h2', 'h3', 'h4', 'h5', 'h6', 'br', 'p']


def clean_for_user_description(html):
Expand Down
Loading
Loading