From e4bf2d86ad9fc23805fda8ed7c27720091bff9e5 Mon Sep 17 00:00:00 2001 From: Pengwius Date: Thu, 7 Jan 2021 00:48:06 +0100 Subject: [PATCH] Commit for MarcinK50 --- .github/workflows/python-app.yml | 29 +++++ app/login.py | 58 ++++----- app/templatetags/__init__.py | 0 app/templatetags/custom_filters_tags.py | 85 ------------- app/views.py | 136 ++------------------- files/js/login.js | 2 +- templates/content.html | 36 ++++++ templates/frekwencja.html | 86 ------------- templates/index.html | 1 - templates/messages_content.html | 11 -- templates/oceny.html | 76 ------------ templates/plan.html | 71 ----------- templates/sprawdziany.html | 156 ------------------------ templates/uwagi.html | 56 --------- templates/wiadomosci.html | 47 ------- templates/zadania.html | 120 ------------------ tests/test_urls.py | 36 +----- wulkanowy/urls.py | 11 +- 18 files changed, 108 insertions(+), 909 deletions(-) create mode 100644 .github/workflows/python-app.yml delete mode 100644 app/templatetags/__init__.py delete mode 100644 app/templatetags/custom_filters_tags.py create mode 100644 templates/content.html delete mode 100644 templates/frekwencja.html delete mode 100644 templates/messages_content.html delete mode 100644 templates/oceny.html delete mode 100644 templates/plan.html delete mode 100644 templates/sprawdziany.html delete mode 100644 templates/uwagi.html delete mode 100644 templates/wiadomosci.html delete mode 100644 templates/zadania.html diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..f8b8b1b --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,29 @@ + name: Python application + on: [push] + jobs: + build: + runs-on: ubuntu-latest + env: + SECRET_KEY: SECRET_KEY123 + services: + postgres: + image: postgres:10.8 + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: psycopg2 prerequisites + run: sudo apt-get install python-dev libpq-dev + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest-django + - name: Run tests + run: python manage.py test diff --git a/app/login.py b/app/login.py index 0f0a11a..f93af33 100644 --- a/app/login.py +++ b/app/login.py @@ -1,6 +1,7 @@ import os import sys import requests +from django.http import JsonResponse from django import template from django.utils.safestring import mark_safe from django.shortcuts import render @@ -10,31 +11,23 @@ from django.shortcuts import redirect from bs4 import BeautifulSoup import datetime -oun = '' -s = requests.Session() -symbol = '' +def sender(url, loginName, Password, params_names, fail_phrase, symbol, diary_url): + data = [params_names[0], loginName, params_names[1], Password] -def sender(url, loginName, Password, params_names, fail_phrase, sym, diary_url): - global symbol - data = [] - data.append((params_names[0], loginName, params_names[1], Password)) - symbol = sym + sender_return = send(url, data, fail_phrase, diary_url, symbol) + print(sender_return) + if sender_return == {'success': False}: + return {'success': False} + else: + return sender_return - for index, single_data in enumerate(data): - index += 1 - if send(url, single_data, fail_phrase, diary_url): - return True - else: - return False - -def send(url, data, fail, diary_url): +def send(url, data, fail, diary_url, symbol): + s = requests.Session() ready_data = {data[0]: data[1], data[2]: data[3]} page = s.post(url=url, data=ready_data) - print(page.text) if fail in page.text: - return False + return {'success': False} else: - global symbol if diary_url == 'http://cufs.fakelog.cf/': page = s.get('http://cufs.fakelog.cf/powiatwulkanowy/FS/LS?wa=wsignin1.0&wtrealm=http://uonetplus.fakelog.localhost:300/powiatwulkanowy/LoginEndpoint.aspx&wctx=http://uonetplus.fakelog.localhost:300/powiatwulkanowy/LoginEndpoint.aspx') bs = BeautifulSoup(page.text, 'html.parser') @@ -42,17 +35,9 @@ def send(url, data, fail, diary_url): cert = bs.find('input', {'name': 'wresult'})['value'] wctx = bs.find('input', {'name': 'wctx'})['value'] - print(wa) - print('------------------------------------------------------------') - print(cert) - print('------------------------------------------------------------') - print(wctx) - print('------------------------------------------------------------') - crtr = s.post(url=wctx, headers={"User-Agent": "Wulkanowy-web :)"}, data={"wa": wa, "wresult": cert, "wctx": wctx}) bs = BeautifulSoup(crtr.content, 'html.parser') - global oun for a in bs.find_all('a', title='Uczeń'): oun = a['href'] break @@ -60,11 +45,11 @@ def send(url, data, fail, diary_url): if diary_url == 'http://cufs.fakelog.cf/': oun = 'http://uonetplus-uczen.fakelog.cf/powiatwulkanowy/123458' - return True + cookies = get_cookies(symbol, oun, s) -def get_cookies(): - global symbol - global oun + return cookies + +def get_cookies(symbol, oun, s): register_r = s.post(oun+'/UczenDziennik.mvc/Get') register_id = register_r.json()['data'][0]['Okresy'][0]['Id'] @@ -83,4 +68,13 @@ def get_cookies(): school_year = register_r.json()['data'][0]['DziennikRokSzkolny'] - return [register_id, register_r, oun, s, date, school_year, symbol] \ No newline at end of file + data = { + 'register_id': register_id, + 'register_r': register_r.json(), + 'oun': oun, + 'date': date, + 'school_year': school_year, + 'symbol': symbol, + } + + return data \ No newline at end of file diff --git a/app/templatetags/__init__.py b/app/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/templatetags/custom_filters_tags.py b/app/templatetags/custom_filters_tags.py deleted file mode 100644 index 3bb70e0..0000000 --- a/app/templatetags/custom_filters_tags.py +++ /dev/null @@ -1,85 +0,0 @@ -from django import template -from django.utils.safestring import mark_safe -from app.login import get_cookies -from app.API.homework import prepare_homework_for_display - -register = template.Library() - -@register.filter -def return_item(l, i): - try: - if l[i] == []: - return ['Brak Ocen'] - else: - return l[i] - except: - return None - -@register.filter -def set_color(grade): - if grade == '6' or grade == '6-': - return '#3dbbf5' - elif grade == '5' or grade == '5-' or grade == '5+': - return '#4caf50' - elif grade == '4' or grade == '4-' or grade == '4+': - return '#a0c431' - elif grade == '3' or grade == '3-' or grade == '3+': - return '#ffb940' - elif grade == '2' or grade == '2-' or grade == '2+': - return '#ff774d' - elif grade == '1' or grade == '1+': - return '#d43f3f' - else: - return '#607d8b' - -@register.filter -def simple_data(exam): - return_html = [] - if exam != {}: - for exams in exam: - lesson = exam[exams]['Przedmiot'] - if exam[exams]['Opis'] == '': - description = 'Brak Opisu' - else: - description = exam[exams]['Opis'] - date = exam[exams]['Data'] - if return_html == []: - return_html.append([lesson, description, date]) - else: - return_html.append([lesson, description, date]) - return return_html - else: - return mark_safe('Brak Sprawdzianów') - -homework_all = None - -@register.filter -def week_homework(no): - global homework_all - cookie = get_cookies() - if homework_all == None: - homework_all = prepare_homework_for_display(cookie[0], cookie[1], cookie[2], cookie[3], cookie[5]) - homework = [] - - for i in range(4): - homework.append(homework_all[i][no]) - - return homework - -@register.filter -def points_color(points): - if int(points) < 0: - return 'red;' - elif int(points) > 0: - return 'green;' - else: - return 'black;' - -@register.filter -def suffix(points): - if int(points) == 0 or int(points) >= 5 or int(points) <= -5: - return points+' punktów' - elif int(points) == -1 or int(points) == 1: - return points+' punkt' - elif int(points) > -5 and int(points) <= -2: - return points+' punkty' \ No newline at end of file diff --git a/app/views.py b/app/views.py index f1e9308..9c35e17 100644 --- a/app/views.py +++ b/app/views.py @@ -2,9 +2,9 @@ from requests import get from django.http import HttpResponse, JsonResponse from django.shortcuts import render import json -from .login import sender, get_cookies from django.shortcuts import redirect from django.contrib.sessions.models import Session +from .login import sender from .API.grades import prepare_grades_for_display from .API.exams import prepare_exams_for_display from .API.timetable import prepare_timetable_for_display @@ -12,126 +12,12 @@ from .API.notes import prepare_notes_for_display from .API.attendance import prepare_attendance_for_display from .API.messages import get_messages +#views def default_view(request, *args, **kwargs): return render(request, 'index.html') - -def grades_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - grades = prepare_grades_for_display(cookies[0], cookies[1], cookies[2], cookies[3]) - - grade = {} - description = {} - - for i in grades[1]: - grade.update({i: []}) - description.update({i: []}) - for items in grades[0][i]: - grade[i].append(items['Ocena']) - description[i].append(items['Opis']) - - content = {'gc': grade, 'dc': description, 'lesson': grades[1]} - return render(request, 'oceny.html', content) - else: - return redirect(default_view) - -def homework_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - return render(request, 'zadania.html') - else: - return redirect(default_view) - -def timetable_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - timetable = prepare_timetable_for_display(cookies[0], cookies[1], cookies[2], cookies[3], cookies[4]) - - hour = {} - - for i in timetable['hour']: - hour.update({i[0]: []}) - hour[i[0]].append(i[1]) - hour[i[0]].append(i[2]) - - content = { - 'hour': hour, - 'monday': timetable['monday'], - 'tuesday': timetable['tuesday'], - 'wednesday': timetable['wednesday'], - 'thrusday': timetable['thrusday'], - 'friday': timetable['friday'] - } - - return render(request, 'plan.html', content) - else: - return redirect(default_view) - -def attendance_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - attendance = prepare_attendance_for_display(cookies[0], cookies[1], cookies[2], cookies[3], cookies[4]) - content = {'attendance': attendance} - - return render(request, 'frekwencja.html', content) - else: - return redirect(default_view) - -def notes_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - notes = prepare_notes_for_display(cookies[0], cookies[1], cookies[2], cookies[3]) - - content = { - 'notes': notes[0], - 'achievements': notes[1] - } - - return render(request, 'uwagi.html', content) - else: - return redirect(default_view) - -def exams_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - print(cookies) - exams = prepare_exams_for_display(cookies[0], cookies[1], cookies[2], cookies[3], cookies[4], cookies[5]) - - positions = [] - - for x in range(4): - positions.append(exams[x]) - - content = {'content': positions} - - return render(request, 'sprawdziany.html', content) - else: - return redirect(default_view) - -def messages_view(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - messages = get_messages(cookies[0], cookies[1], cookies[2], cookies[3], cookies[4], cookies[5], cookies[6]) - content = {'messages': messages[0]} - return render(request, 'wiadomosci.html', content) - else: - return redirect(default_view) - -def change_messages_content(request, *args, **kwargs): - if request.session.has_key('is_logged'): - cookies = get_cookies() - messages = get_messages(cookies[0], cookies[1], cookies[2], cookies[3], cookies[4], cookies[5], cookies[6]) - id = request.GET.get('id') - - if id == 'received': - content = {'messages': messages[0]} - elif id == 'sent': - content = {'messages': messages[1]} - elif id == 'deleted': - content = {'messages': messages[2]} - return render(request, 'messages_content.html', content) - else: - return redirect(default_view) +def content_view(request, *args, **kwargs): + return render(request, 'content.html') #API def login(request, *args, **kwargs): @@ -146,14 +32,12 @@ def login(request, *args, **kwargs): else: link = 'http://cufs.fakelog.cf/powiatwulkanowy/FS/LS?wa=wsignin1.0&wtrealm=http://uonetplus.fakelog.localhost:300/powiatwulkanowy/LoginEndpoint.aspx&wctx=http://uonetplus.fakelog.localhost:300/powiatwulkanowy/LoginEndpoint.aspx' sender_return = sender(link, loginName, Password, ('loginName', 'Password'), 'Zła nazwa użytkownika lub hasło', symbol, diary_url) - print(sender_return) - if sender_return == False: - data = { + if sender_return == {'success': False}: + data_response = { 'success': False } - elif sender_return == True: + else: request.session['is_logged'] = True - data = { - 'success': True - } - return JsonResponse(data) + data_response = {'success': True, 'data': sender_return} + print(data_response) + return JsonResponse(data_response) \ No newline at end of file diff --git a/files/js/login.js b/files/js/login.js index a3e332d..2edc4af 100644 --- a/files/js/login.js +++ b/files/js/login.js @@ -31,7 +31,7 @@ const login = () => { body: JSON.stringify(data) }).then(response => response.json()).then(data => { if(data['success']){ - window.location.href = "/oceny/" + window.location.href = "/content/" } else{ document.querySelector('#error').innerHTML = 'Nieprawidłowy login, hasło lub symbol' diff --git a/templates/content.html b/templates/content.html new file mode 100644 index 0000000..4e8a230 --- /dev/null +++ b/templates/content.html @@ -0,0 +1,36 @@ +{% load static %} + + + + + + + + + + + + + + + Wulkanowy | Aplikacja ucznia i rodzica + + +
+ +
+ +
+ + \ No newline at end of file diff --git a/templates/frekwencja.html b/templates/frekwencja.html deleted file mode 100644 index 40da5b4..0000000 --- a/templates/frekwencja.html +++ /dev/null @@ -1,86 +0,0 @@ -{% load static %} -{% load custom_filters_tags %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
- -
-
-
PONIEDZIAŁEK
- {% if 0 in attendance %} - {% for i in attendance.0 %} -
{{ i.Content|force_escape }}
{{ i.Lesson|force_escape }}
- {% endfor %} - {% else %} -
Brak danych o frekwencji
- {% endif %} -
-
-
WTOREK
- {% if 1 in attendance %} - {% for i in attendance.1 %} -
{{ i.Content|force_escape }}
{{ i.Lesson|force_escape }}
- {% endfor %} - {% else %} -
Brak danych o frekwencji
- {% endif %} -
-
-
ŚRODA
- {% if 2 in attendance %} - {% for i in attendance.2 %} -
{{ i.Content|force_escape }}
{{ i.Lesson|force_escape }}
- {% endfor %} - {% else %} -
Brak danych o frekwencji
- {% endif %} -
-
-
CZWARTEK
- {% if 3 in attendance %} - {% for i in attendance.3 %} -
{{ i.Content|force_escape }}
{{ i.Lesson|force_escape }}
- {% endfor %} - {% else %} -
Brak danych o frekwencji
- {% endif %} -
-
-
PIĄTEK
- {% if 4 in attendance %} - {% for i in attendance.4 %} -
{{ i.Content|force_escape }}
{{ i.Lesson|force_escape }}
- {% endfor %} - {% else %} -
Brak danych o frekwencji
- {% endif %} -
-
-
- - \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index f684936..0fc180b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,7 +13,6 @@ - Wulkanowy | Aplikacja ucznia i rodzica diff --git a/templates/messages_content.html b/templates/messages_content.html deleted file mode 100644 index 77d6e2f..0000000 --- a/templates/messages_content.html +++ /dev/null @@ -1,11 +0,0 @@ -{% for i in messages %} - {% if 'Sender' in i %} -
Temat: {{ i.Subject|force_escape }}
Nadawca: {{ i.Sender|force_escape }}
Data: {{ i.Date|force_escape }}
- {% else %} -
Temat: {{ i.Subject|force_escape }}
Obiorca: - {% for j in i.Recipients %} - {{ j.Name|force_escape }} - {% endfor %} -
Data: {{ i.Date|force_escape }}
- {% endif %} -{% endfor %} \ No newline at end of file diff --git a/templates/oceny.html b/templates/oceny.html deleted file mode 100644 index 84bf4ef..0000000 --- a/templates/oceny.html +++ /dev/null @@ -1,76 +0,0 @@ -{% load static %} -{% load custom_filters_tags %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
- -
- {% for l in lesson %} -
-
  • {{ l }} -
      -
    • - {% for i in gc %} - {% if i == l %} -
      -
      - {% for grade in gc|return_item:i %} - {% if grade != 'Brak Ocen' %} -
      {{ grade }}
      - {{ content|force_escape }} -
      - {% endif %} - {% endfor %} -
      -
      - {% for description in dc|return_item:i %} - {% if description == 'Brak Ocen' %} -
      Brak Ocen
      -
      - {% elif description == '' %} -
      Brak Opisu
      -
      - {% else %} -
      {{ description|force_escape }}
      -
      - {% endif %} - {% endfor%} -
      -
      - {% endif %} - {% endfor %} -
    • -
    -
  • -
    -
    - {% endfor %} -
    -
    - - \ No newline at end of file diff --git a/templates/plan.html b/templates/plan.html deleted file mode 100644 index 0ac3a29..0000000 --- a/templates/plan.html +++ /dev/null @@ -1,71 +0,0 @@ -{% load static %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
    - -
    -
    -
    GODZINA
    - {% for hours in hour.items %} -
    {{ hours.1.0 }} - {{ hours.1.1 }}
    - {% endfor %} -
    -
    -
    PONIEDZIAŁEK
    - {% for lessons in monday %} -
    {{ lessons }}
    - {% endfor %} -
    -
    -
    WTOREK
    - {% for lessons in tuesday %} -
    {{ lessons }}
    - {% endfor %} -
    -
    -
    ŚRODA
    - {% for lessons in wednesday %} -
    {{ lessons }}
    - {% endfor %} -
    -
    -
    CZWARTEK
    - {% for lessons in thrusday %} -
    {{ lessons }}
    - {% endfor %} -
    -
    -
    PIĄTEK
    - {% for lessons in friday %} -
    {{ lessons }}
    - {% endfor %} -
    -
    -
    - - \ No newline at end of file diff --git a/templates/sprawdziany.html b/templates/sprawdziany.html deleted file mode 100644 index d3990be..0000000 --- a/templates/sprawdziany.html +++ /dev/null @@ -1,156 +0,0 @@ -{% load static %} -{% load custom_filters_tags %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
    - -
    -
    -
    PONIEDZIAŁEK
    - {% for i in content %} - {% if i.0|simple_data == 'Brak Sprawdzianów' %} -
    Brak Sprawdzianów
    - {% else %} -
    {% for x in i.0|simple_data %} - {% if x.0 == i.0.0.Przedmiot %} - {% if x.1 == 'Brak Opisu' %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% else %} - {% if x.1 == 'Brak Opisu' %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% endif %} - {% endfor %}
    - {% endif %} - {% endfor %} -
    -
    -
    WTOREK
    - {% for i in content %} - {% if i.1|simple_data == 'Brak Sprawdzianów' %} -
    Brak Sprawdzianów
    - {% else %} -
    {% for x in i.1|simple_data %} - {% if x.0 == i.1.0.Przedmiot %} - {% if x.1 == 'Brak Opisu' %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% else %} - {% if x.1 == 'Brak Opisu' %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% endif %} - {% endfor %}
    - {% endif %} - {% endfor %} -
    -
    -
    ŚRODA
    - {% for i in content %} - {% if i.2|simple_data == 'Brak Sprawdzianów' %} -
    Brak Sprawdzianów
    - {% else %} -
    {% for x in i.2|simple_data %} - {% if x.0 == i.2.0.Przedmiot %} - {% if x.1 == 'Brak Opisu' %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% else %} - {% if x.1 == 'Brak Opisu' %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% endif %} - {% endfor %}
    - {% endif %} - {% endfor %} -
    -
    -
    CZWARTEK
    - {% for i in content %} - {% if i.3|simple_data == 'Brak Sprawdzianów' %} -
    Brak Sprawdzianów
    - {% else %} -
    {% for x in i.3|simple_data %} - {% if x.0 == i.3.0.Przedmiot %} - {% if x.1 == 'Brak Opisu' %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% else %} - {% if x.1 == 'Brak Opisu' %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% endif %} - {% endfor %}
    - {% endif %} - {% endfor %} -
    -
    -
    PIĄTEK
    - {% for i in content %} - {% if i.4|simple_data == 'Brak Sprawdzianów' %} -
    Brak Sprawdzianów
    - {% else %} -
    {% for x in i.4|simple_data %} - {% if x.0 == i.4.0.Przedmiot %} - {% if x.0 == 'Brak Opisu' %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} - {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% else %} - {% if x.1 == 'Brak Opisu' %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% else %} -
    {{ x.0|force_escape }}
    {{ x.1|force_escape }}
    {{ x.2|force_escape }}
    - {% endif %} - {% endif %} - {% endfor %}
    - {% endif %} - {% endfor %} -
    -
    -
    - - \ No newline at end of file diff --git a/templates/uwagi.html b/templates/uwagi.html deleted file mode 100644 index 44c2537..0000000 --- a/templates/uwagi.html +++ /dev/null @@ -1,56 +0,0 @@ -{% load static %} -{%load custom_filters_tags %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
    - -
    -
    -
    UWAGI
    - {% if notes.0.content == 'Brak uwag!' %} -
    Brak uwag!
    - {% else %} - {% for i in notes %} -
    {{ i.content|force_escape }}
    {{ i.category|force_escape }}
    {{ i.date|force_escape }}
    {{ i.teacher|force_escape }}
    {{ i.points|suffix|force_escape }}
    - {% endfor %} - {% endif %} -
    -
    -
    OSIĄGNIĘCIA
    - {% if achievements.0.content == 'Brak osiągnięć!' %} -
    Brak osiągnięć!
    - {% else %} - {% for i in achievements %} -
    {{ i.content|force_escape }}
    - {% endfor %} - {% endif %} -
    -
    -
    - - \ No newline at end of file diff --git a/templates/wiadomosci.html b/templates/wiadomosci.html deleted file mode 100644 index 424ac87..0000000 --- a/templates/wiadomosci.html +++ /dev/null @@ -1,47 +0,0 @@ -{% load static %} -{% load custom_filters_tags %} - - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
    - -
    -
    -
    ODEBRANE
    -
    WYSŁANE
    -
    USUNIĘTE
    -
    -
    - {% for i in messages %} -
    Temat: {{ i.Subject|force_escape }}
    Nadawca: {{ i.Sender|force_escape }}
    Data: {{ i.Date|force_escape }}
    - {% endfor %} -
    -
    -
    - - \ No newline at end of file diff --git a/templates/zadania.html b/templates/zadania.html deleted file mode 100644 index ccad0d7..0000000 --- a/templates/zadania.html +++ /dev/null @@ -1,120 +0,0 @@ -{% load static %} -{% load custom_filters_tags %} - - - - - - - - - - - - - - Wulkanowy | Aplikacja ucznia i rodzica - - -
    - -
    -
    -
    PONIEDZIAŁEK
    - {% for i in 0|week_homework %} -
    - {% if i.0 == 'Brak zadań domowych na ten dzień' %} - Brak zadań domowych na ten dzień - {% else %} - {% for j in i %} - {% if j == i.0 %} - {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% else %} -
    {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% endif %} - {% endfor %} - {% endif %}
    - {% endfor %} -
    -
    -
    WTOREK
    - {% for i in 1|week_homework %} -
    - {% if i.0 == 'Brak zadań domowych na ten dzień' %} - Brak zadań domowych na ten dzień - {% else %} - {% for j in i %} - {% if j == i.0 %} - {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% else %} -
    {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% endif %} - {% endfor %} - {% endif %}
    - {% endfor %} -
    -
    -
    ŚRODA
    - {% for i in 2|week_homework %} -
    - {% if i.0 == 'Brak zadań domowych na ten dzień' %} - Brak zadań domowych na ten dzień - {% else %} - {% for j in i %} - {% if j == i.0 %} - {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% else %} -
    {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% endif %} - {% endfor %} - {% endif %}
    - {% endfor %} -
    -
    -
    CZWARTEK
    - {% for i in 3|week_homework %} -
    - {% if i.0 == 'Brak zadań domowych na ten dzień' %} - Brak zadań domowych na ten dzień - {% else %} - {% for j in i %} - {% if j == i.0 %} - {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% else %} -
    {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% endif %} - {% endfor %} - {% endif %}
    - {% endfor %} -
    -
    -
    PIĄTEK
    - {% for i in 4|week_homework %} -
    - {% if i.0 == 'Brak zadań domowych na ten dzień' %} - Brak zadań domowych na ten dzień - {% else %} - {% for j in i %} - {% if j == i.0 %} - {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% else %} -
    {{ j.Przedmiot }}
    {{ j.Opis }}
    {{ j.Data }} - {% endif %} - {% endfor %} - {% endif %}
    - {% endfor %} -
    -
    - - \ No newline at end of file diff --git a/tests/test_urls.py b/tests/test_urls.py index b12caa7..6766dc3 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -1,6 +1,6 @@ from django.test import SimpleTestCase from django.urls import reverse, resolve -from app.views import default_view, grades_view, timetable_view, exams_view, homework_view, attendance_view, messages_view, notes_view, change_messages_content +from app.views import default_view, content_view from app.views import login class TestUrls(SimpleTestCase): @@ -9,37 +9,9 @@ class TestUrls(SimpleTestCase): url = reverse('home') self.assertEquals(resolve(url).func, default_view) - def test_grades_is_resolved(self): - url = reverse('grades') - self.assertEquals(resolve(url).func, grades_view) - - def test_timetable_is_resolved(self): - url = reverse('timetable') - self.assertEquals(resolve(url).func, timetable_view) - - def test_exams_is_resolved(self): - url = reverse('exams') - self.assertEquals(resolve(url).func, exams_view) - - def test_homework_is_resolved(self): - url = reverse('homework') - self.assertEquals(resolve(url).func, homework_view) - - def test_attendance_is_resolved(self): - url = reverse('attendance') - self.assertEquals(resolve(url).func, attendance_view) - - def test_messages_is_resolved(self): - url = reverse('messages') - self.assertEquals(resolve(url).func, messages_view) - - def test_notes_is_resolved(self): - url = reverse('notes') - self.assertEquals(resolve(url).func, notes_view) - - def test_cmc_is_resolved(self): - url = reverse('cmc') - self.assertEquals(resolve(url).func, change_messages_content) + def test_content_is_resolved(self): + url = reverse('content') + self.assertEquals(resolve(url).func, content_view) #API def test_login_is_resolved(self): diff --git a/wulkanowy/urls.py b/wulkanowy/urls.py index cfa9af2..fb6d9a3 100644 --- a/wulkanowy/urls.py +++ b/wulkanowy/urls.py @@ -16,20 +16,13 @@ Including another URLconf from django.urls import path from django.contrib.staticfiles.urls import staticfiles_urlpatterns -from app.views import default_view, grades_view, timetable_view, exams_view, homework_view, attendance_view, messages_view, notes_view, change_messages_content +from app.views import default_view, content_view from app.views import login urlpatterns = [ #views path('', default_view, name='home'), - path('oceny/', grades_view, name='grades'), - path('plan/', timetable_view, name='timetable'), - path('sprawdziany/', exams_view, name='exams'), - path('zadania/', homework_view, name='homework'), - path('frekwencja/', attendance_view, name='attendance'), - path('wiadomosci/', messages_view, name='messages'), - path('uwagi/', notes_view, name='notes'), - path('change_messages_content/', change_messages_content, name='cmc'), + path('content/', content_view, name='content'), #api path('api/login', login, name='login') ]