Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • konstantin/akplanning
  • matedealer/akplanning
  • kif/akplanning
  • mirco/akplanning
  • lordofthevoid/akplanning
  • voidptr/akplanning
  • xayomer/akplanning-fork
  • mollux/akplanning
  • neumantm/akplanning
  • mmarx/akplanning
  • nerf/akplanning
  • felix_bonn/akplanning
  • sebastian.uschmann/akplanning
13 results
Show changes
Commits on Source (781)
Showing
with 852 additions and 4 deletions
#!/bin/sh
function wait_for_db()
{
while ! ./manage.py sqlflush > /dev/null 2>&1 ;do
echo "Waiting for the db to be ready."
sleep 1
done
}
if [ "$SECRET_KEY" == "" ] ;then
echo "Need the environment variable SECRET_KEY."
exit 1
fi
echo "" > ./AKPlanning/settings_secrets.py # Reset file in case we ran before
echo "SECRET_KEY = '$SECRET_KEY'" >> ./AKPlanning/settings_secrets.py
echo "HOSTS = $HOSTS" >> ./AKPlanning/settings_secrets.py
echo "DB_NAME = '$DB_NAME'" >> ./AKPlanning/settings_secrets.py
echo "DB_USER = '$DB_USER'" >> ./AKPlanning/settings_secrets.py
echo "DB_PASSWORD = '$DB_PASSWORD'" >> ./AKPlanning/settings_secrets.py
echo "DB_HOST = '$DB_HOST'" >> ./AKPlanning/settings_secrets.py
if [ "$AUTO_MIGRATE_DB" == "true" ] ;then
wait_for_db
echo "Applying DB migrations"
./manage.py migrate
fi
if [ "$DJANGO_SUPERUSER_PASSWORD" != "" ] ;then
wait_for_db
echo "Trying to create superuser."
./manage.py createsuperuser --noinput
fi
env | while IFS= read -r line; do
value=${line#*=}
name=${line%%=*}
case $name in EXTRA_DJANGO_SETTING*)
echo -e "$value" > "./AKPlanning/settings/$name.py"
esac
done
./manage.py collectstatic --noinput
./manage.py compilemessages -l de_DE
uwsgi --ini .docker/uwsgi.ini
uwsgi==2.0.28
[uwsgi]
socket = 0.0.0.0:3035
wsgi-file = AKPlanning/wsgi.py
env = DJANGO_SETTINGS_MODULE=AKPlanning.settings_production
processes = 4
threads = 2
apache-akplanning.conf
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CONTRIBUTORS.md
.git
.gitignore
.gitlab-ci.yml
INSTALL.md
LICENSE.md
README.md
uwsgi-akplanning.ini
...@@ -10,6 +10,9 @@ AKPlanning/settings/ ...@@ -10,6 +10,9 @@ AKPlanning/settings/
# static files generated by django # static files generated by django
/static/ /static/
# Database backups
backups/
# Created by https://www.gitignore.io/api/python,django,virtualenv,pycharm+all # Created by https://www.gitignore.io/api/python,django,virtualenv,pycharm+all
# Edit at https://www.gitignore.io/?templates=python,django,virtualenv,pycharm+all # Edit at https://www.gitignore.io/?templates=python,django,virtualenv,pycharm+all
......
image: python:3.11
services:
- mysql
variables:
MYSQL_DATABASE: "test"
MYSQL_ROOT_PASSWORD: "mysql"
MYSQL_USER: "django"
MYSQL_PASSWORD: "mysql"
MYSQL_HOST: "mysql"
cache:
paths:
- ~/.cache/pip/
.before_script_template:
before_script:
- python -V # Print out python version for debugging
- apt-get -qq update
- apt-get -qq install -y python3-virtualenv python3 python3-dev python3-pip gettext default-mysql-client default-libmysqlclient-dev
- ./Utils/setup.sh --ci
- mkdir -p public/badges public/lint
- echo undefined > public/badges/$CI_JOB_NAME.score
- source venv/bin/activate
- pip install pylint-gitlab pylint-django
- mysql --version
migrations:
extends: .before_script_template
script:
- source venv/bin/activate
- ./manage.py makemigrations --dry-run --check
test:
extends: .before_script_template
script:
- source venv/bin/activate
- echo "GRANT ALL on *.* to '${MYSQL_USER}';"| mysql -u root --password="${MYSQL_ROOT_PASSWORD}" -h mysql
- pip install pytest-cov unittest-xml-reporting
- coverage run --source='.' manage.py test --settings AKPlanning.settings_ci
after_script:
- source venv/bin/activate
- coverage report
- coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit: unit.xml
lint:
extends: .before_script_template
stage: test
script:
- pylint --load-plugins pylint_django --django-settings-module=AKPlanning.settings_ci --rcfile pylintrc --exit-zero --output-format=text AK* | tee /tmp/pylint.txt
- sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score
- pylint --load-plugins pylint_django --django-settings-module=AKPlanning.settings_ci --rcfile pylintrc --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter AK* > codeclimate.json
- pylint --load-plugins pylint_django --django-settings-module=AKPlanning.settings_ci --rcfile pylintrc --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter AK* > public/lint/index.html
after_script:
- |
echo "Linting score: $(cat public/badges/$CI_JOB_NAME.score)"
artifacts:
paths:
- public
reports:
codequality: codeclimate.json
when: always
doc:
extends: .before_script_template
stage: test
script:
- cd docs
- make html
- cd ..
artifacts:
paths:
- docs/_build/html
pages:
stage: deploy
image: alpine:latest
script:
- echo
artifacts:
paths:
- public
only:
refs:
- main
# Register your models here. from django.contrib import admin
from AKDashboard.models import DashboardButton
@admin.register(DashboardButton)
class DashboardButtonAdmin(admin.ModelAdmin):
"""
Admin interface for dashboard buttons
"""
list_display = ['text', 'url', 'event']
list_filter = ['event']
search_fields = ['text', 'url']
list_display_links = ['text']
...@@ -2,4 +2,7 @@ from django.apps import AppConfig ...@@ -2,4 +2,7 @@ from django.apps import AppConfig
class AkdashboardConfig(AppConfig): class AkdashboardConfig(AppConfig):
"""
App configuration for dashboard (default)
"""
name = 'AKDashboard' name = 'AKDashboard'
[
{
"model": "AKDashboard.dashboardbutton",
"pk": 1,
"fields": {
"text": "Wiki",
"url": "http://wiki.kif.rocks",
"icon": "fab,wikipedia-w",
"color": 2,
"event": 2
}
}
]
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-01 17:28+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: AKDashboard/models.py:21
msgid "Dashboard Button"
msgstr "Dashboard-Button"
#: AKDashboard/models.py:22
msgid "Dashboard Buttons"
msgstr "Dashboard-Buttons"
#: AKDashboard/models.py:32
msgid "Text"
msgstr "Text"
#: AKDashboard/models.py:33
msgid "Text that will be shown on the button"
msgstr "Text, der auf dem Button angezeigt wird"
#: AKDashboard/models.py:34
msgid "Link URL"
msgstr "Link-URL"
#: AKDashboard/models.py:34
msgid "URL this button links to"
msgstr "URL auf die der Button verweist"
#: AKDashboard/models.py:35
msgid "Icon"
msgstr "Symbol"
#: AKDashboard/models.py:37
msgid "Button Style"
msgstr "Stil des Buttons"
#: AKDashboard/models.py:37
msgid "Style (Color) of this button (bootstrap class)"
msgstr "Stiel (Farbe) des Buttons (Bootstrap-Klasse)"
#: AKDashboard/models.py:39
msgid "Event"
msgstr "Veranstaltung"
#: AKDashboard/models.py:39
msgid "Event this button belongs to"
msgstr "Veranstaltung, zu der dieser Button gehört"
#: AKDashboard/templates/AKDashboard/dashboard.html:18
#: AKDashboard/templates/AKDashboard/dashboard_event.html:29
#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:53
msgid "Write to organizers of this event for questions and comments"
msgstr ""
"Kontaktiere die Organisator*innen des Events bei Fragen oder Kommentaren"
#: AKDashboard/templates/AKDashboard/dashboard.html:24
msgid "Old events"
msgstr "Frühere Veranstaltungen"
#: AKDashboard/templates/AKDashboard/dashboard.html:34
msgid "Currently, there are no Events!"
msgstr "Aktuell gibt es keine Events!"
#: AKDashboard/templates/AKDashboard/dashboard.html:37
msgid "Please contact an administrator if you want to use AKPlanning."
msgstr ""
"Bitte kontaktiere eine*n Administrator*in, falls du AKPlanning verwenden "
"möchtest."
#: AKDashboard/templates/AKDashboard/dashboard_event.html:19
msgid "Recent"
msgstr "Kürzlich"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:18
#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:20
msgid "AK List"
msgstr "AK-Liste"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:29
msgid "Current AKs"
msgstr "Aktuelle AKs"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:36
msgid "AK Wall"
msgstr "AK-Wall"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:44
#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:30
msgid "Schedule"
msgstr "AK-Plan"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:55
msgid "AK Submission"
msgstr "AK-Einreichung"
#: AKDashboard/templates/AKDashboard/dashboard_row.html:63
#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:39
msgid "AK History"
msgstr "AK-Verlauf"
#: AKDashboard/views.py:69
#, python-format
msgid "New AK: %(ak)s."
msgstr "Neuer AK: %(ak)s."
#: AKDashboard/views.py:72
#, python-format
msgid "AK \"%(ak)s\" edited."
msgstr "AK \"%(ak)s\" bearbeitet."
#: AKDashboard/views.py:75
#, python-format
msgid "AK \"%(ak)s\" deleted."
msgstr "AK \"%(ak)s\" gelöscht."
#: AKDashboard/views.py:90
#, python-format
msgid "AK \"%(ak)s\" (re-)scheduled."
msgstr "AK \"%(ak)s\" (um-)geplant."
# Generated by Django 2.2.6 on 2020-01-12 23:30
from django.db import migrations, models
import django.db.models.deletion
import fontawesome_6.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('AKModel', '0026_akslot_updated'),
]
operations = [
migrations.CreateModel(
name='DashboardButton',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.CharField(help_text='Text that will be shown on the button', max_length=50, verbose_name='Text')),
('url', models.URLField(help_text='URL this button links to', verbose_name='Link URL')),
('icon', fontawesome_6.fields.IconField(blank=True, default='external-link-alt', help_text='Symbol represeting this button.', max_length=60, verbose_name='Icon')),
('color', models.PositiveSmallIntegerField(choices=[(0, 'primary'), (1, 'success'), (2, 'info'), (3, 'warning'), (4, 'danger')], default=0, help_text='Style (Color) of this button (bootstrap class)', verbose_name='Button Style')),
('event', models.ForeignKey(help_text='Event this button belongs to', on_delete=django.db.models.deletion.CASCADE, to='AKModel.Event', verbose_name='Event')),
],
options={
'verbose_name': 'Dashboard Button',
'verbose_name_plural': 'Dashboard Buttons',
},
),
]
# Generated by Django 3.2.16 on 2023-01-03 16:50
from django.db import migrations
import fontawesome_6.fields
class Migration(migrations.Migration):
dependencies = [
('AKDashboard', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='dashboardbutton',
name='icon',
field=fontawesome_6.fields.IconField(blank=True, default='external-link-alt', help_text='Symbol represeting this button.', max_length=60, verbose_name='Icon'),
),
]
# Create your models here. from django.db import models
from django.utils.translation import gettext_lazy as _
from fontawesome_6.fields import IconField
from AKModel.models import Event
class DashboardButton(models.Model):
"""
Model for a single dashboard button
Allows to specify
* a text (currently without possibility to translate),
* a color (based on predefined design colors)
* a url the button should point to (internal or external)
* an icon (from the collection of fontawesome)
Each button is associated with a single event and will be deleted when the event is deleted.
"""
class Meta:
verbose_name = _("Dashboard Button")
verbose_name_plural = _("Dashboard Buttons")
COLOR_CHOICES = (
(0, "primary"),
(1, "success"),
(2, "info"),
(3, "warning"),
(4, "danger"),
)
text = models.CharField(max_length=50, blank=False, verbose_name=_("Text"),
help_text=_("Text that will be shown on the button"))
url = models.URLField(blank=False, verbose_name=_("Link URL"), help_text=_("URL this button links to"))
icon = IconField(default="external-link-alt", verbose_name=_("Icon"), help_text="Symbol represeting this button.")
color = models.PositiveSmallIntegerField(choices=COLOR_CHOICES, default=0, blank=False,
verbose_name=_("Button Style"), help_text=_("Style (Color) of this button (bootstrap class)"))
event = models.ForeignKey(to=Event, on_delete=models.CASCADE, blank=False, null=False,
verbose_name=_("Event"), help_text=_("Event this button belongs to"))
def __str__(self):
return f"{self.text} ({self.event})"
.dashboard-row {
margin-bottom: 5em;
}
.dashboard-row-small {
margin-bottom: 3em;
}
.dashboard-row > .row {
margin-left: 0;
padding-bottom: 1em;
}
.dashboard-box .fa {
font-size: 26pt;
}
.dashboard-box span.text {
display: block;
padding-top: 10px;
font-size: 12pt;
}
.dashboard-box {
padding: 2em;
margin-right: 1em;
min-width: 15em;
margin-bottom: 1em;
}
.dashboard-button {
display: inline;
padding: 0;
}
#recent-changes-list {
list-style-type:none;
padding-left: 0;
line-height: 220%;
}
#recent-changes-list li {
font-size: 120%;
font-family:monospace;
}
#recent-changes-list a {
text-decoration: none;
color: #555555;
font-weight: bold;
}
{% extends 'base.html' %}
{% load fontawesome_6 %}
{% load i18n %}
{% load static %}
{% block breadcrumbs %}
<li class="breadcrumb-item">AKPlanning</li>
{% endblock %}
{% block content %}
{% if total_event_count > 0 %}
{% for event in active_and_current_events %}
<div class="dashboard-row">
{% include "AKDashboard/dashboard_row.html" %}
{% if event.contact_email %}
<p>
<a href="mailto:{{ event.contact_email }}">{% fa6_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a>
</p>
{% endif %}
</div>
{% endfor %}
{% if old_event_count > 0 %}
<h2 class="mb-3">{% trans "Old events" %}</h2>
{% for event in old_events %}
<div class="dashboard-row-small">
{% include "AKDashboard/dashboard_row_old_event.html" %}
</div>
{% endfor %}
{% endif %}
{% else %}
<div class="jumbotron">
<h2 class="display-4">
{% trans 'Currently, there are no Events!' %}
</h2>
<p class="lead">
{% trans 'Please contact an administrator if you want to use AKPlanning.' %}
</p>
</div>
{% endif %}
{% endblock %}
{% extends 'base.html' %}
{% load fontawesome_6 %}
{% load i18n %}
{% load static %}
{% load tags_AKModel %}
{% load tz %}
{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'dashboard:dashboard' %}">AKPlanning</a></li>
<li class="breadcrumb-item active">{{ event }}</li>
{% endblock %}
{% block content %}
<div class="dashboard-row">
{% include "AKDashboard/dashboard_row.html" %}
{% if recent_changes|length > 0 %}
<h3 class="mt-1" id="history">{% trans "Recent" %}:</h3>
<ul id="recent-changes-list">
{% for recent in recent_changes %}
<li><a href="{{ recent.link }}">{% fa6_icon recent.icon.0 recent.icon.1 %} {{ recent.text }}</a> <span style="color: #999999;">{{ recent.timestamp | timezone:event.timezone | date:"d.m. H:i" }}</span></li>
{% endfor %}
</ul>
{% endif %}
{% if event.contact_email %}
<p>
<a href="mailto:{{ event.contact_email }}">{% fa6_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a>
</p>
{% endif %}
</div>
{% endblock %}
{% load i18n %}
{% load tags_AKModel %}
{% load fontawesome_6 %}
<h2><a href="{% url 'dashboard:dashboard_event' slug=event.slug %}">{{ event.name }}</a></h2>
<h4 class="text-muted">
{% if event.place %}
<b>{{ event.place }} &middot;</b>
{% endif %}
{{ event | event_month_year }}
</h4>
<div class="mt-2">
{% if 'AKSubmission'|check_app_installed %}
<a class="dashboard-box btn btn-primary"
href="{% url 'submit:ak_list' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-list-ul"></span>
<span class='text'>{% trans 'AK List' %}</span>
</div>
</a>
{% endif %}
{% if 'AKPlan'|check_app_installed %}
{% if not event.plan_hidden or user.is_staff %}
{% if event.active %}
<a class="dashboard-box btn btn-primary"
href="{% url 'plan:plan_overview' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-clock"></span>
<span class='text'>{% trans 'Current AKs' %}</span>
</div>
</a>
<a class="dashboard-box btn btn-primary"
href="{% url 'plan:plan_wall' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-calendar"></span>
<span class='text'>{% trans 'AK Wall' %}</span>
</div>
</a>
{% else %}
<a class="dashboard-box btn btn-primary"
href="{% url 'plan:plan_overview' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-calendar-alt"></span>
<span class='text'>{% trans 'Schedule' %}</span>
</div>
</a>
{% endif %}
{% endif %}
{% endif %}
{% if 'AKSubmission'|check_app_installed and event.active %}
<a class="dashboard-box btn btn-primary"
href="{% url 'submit:submission_overview' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-pencil-alt"></span>
<span class='text'>{% trans 'AK Submission' %}</span>
</div>
</a>
{% endif %}
<a class="dashboard-box btn btn-primary"
href="{% url 'dashboard:dashboard_event' slug=event.slug %}#history">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-history"></span>
<span class='text'>{% trans 'AK History' %}</span>
</div>
</a>
{% for button in event.dashboardbutton_set.all %}
<a class="dashboard-box btn btn-{{ button.get_color_display }}"
href="{{ button.url }}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
{% if button.icon %}<span class="fa">{{ button.icon.as_html }}</span>{% endif %}
<span class='text'>{{ button.text }}</span>
</div>
</a>
{% endfor %}
</div>
{% load i18n %}
{% load tags_AKModel %}
{% load fontawesome_6 %}
<h3><a href="{% url 'dashboard:dashboard_event' slug=event.slug %}">{{ event.name }}</a>
<span class="text-muted">
&middot;
{% if event.place %}
{{ event.place }} &middot;
{% endif %}
{{ event | event_month_year }}
</span>
</h3>
<div class="mt-2">
{% if 'AKSubmission'|check_app_installed %}
<a class="btn btn-primary"
href="{% url 'submit:ak_list' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-list-ul"></span>
<span class='text'>{% trans 'AK List' %}</span>
</div>
</a>
{% endif %}
{% if 'AKPlan'|check_app_installed %}
{% if not event.plan_hidden or user.is_staff %}
<a class="btn btn-primary"
href="{% url 'plan:plan_overview' event_slug=event.slug %}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-calendar-alt"></span>
<span class='text'>{% trans 'Schedule' %}</span>
</div>
</a>
{% endif %}
{% endif %}
<a class="btn btn-primary"
href="{% url 'dashboard:dashboard_event' slug=event.slug %}#history">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
<span class="fa fa-history"></span>
<span class='text'>{% trans 'AK History' %}</span>
</div>
</a>
{% for button in event.dashboardbutton_set.all %}
<a class="btn btn-{{ button.get_color_display }}"
href="{{ button.url }}">
<div class="col-sm-12 col-md-3 col-lg-2 dashboard-button">
{% if button.icon %}<span class="fa">{{ button.icon.as_html }}</span>{% endif %}
<span class='text'>{{ button.text }}</span>
</div>
</a>
{% endfor %}
<a class="btn btn-info"
href=mailto:{{ event.contact_email }}"
title="{% trans 'Write to organizers of this event for questions and comments' %}">
{% fa6_icon "envelope" "fas" %}
</a>
</div>
# Create your tests here. import zoneinfo
from django.apps import apps
from django.test import override_settings, TestCase
from django.urls import reverse
from django.utils.timezone import now
from AKDashboard.models import DashboardButton
from AKModel.models import AK, AKCategory, Event
from AKModel.tests import BasicViewTests
class DashboardTests(TestCase):
"""
Specific Dashboard Tests
"""
@classmethod
def setUpTestData(cls):
"""
Initialize Test database
"""
super().setUpTestData()
cls.event = Event.objects.create(
name="Dashboard Test Event",
slug="dashboardtest",
timezone=zoneinfo.ZoneInfo("Europe/Berlin"),
start=now(),
end=now(),
active=True,
plan_hidden=False,
)
cls.default_category = AKCategory.objects.create(
name="Test Category",
event=cls.event,
)
def test_dashboard_view(self):
"""
Check that the main dashboard is reachable
(would also be covered by generic view testcase below)
"""
url = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
def test_nonexistent_dashboard_view(self):
"""
Make sure there is no dashboard for an non-existing event
"""
url = reverse('dashboard:dashboard_event', kwargs={"slug": "nonexistent-event"})
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
@override_settings(DASHBOARD_SHOW_RECENT=True)
def test_history(self):
"""
Test displaying of history
For the sake of that test, the setting to show recent events in dashboard is enforced to be true
regardless of the default configuration currently in place
"""
url = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
# History should be empty
response = self.client.get(url)
self.assertQuerySetEqual(response.context["recent_changes"], [])
AK.objects.create(
name="Test AK",
category=self.default_category,
event=self.event,
)
# History should now contain one AK (Test AK)
response = self.client.get(url)
self.assertEqual(len(response.context["recent_changes"]), 1)
self.assertEqual(response.context["recent_changes"][0]['text'], "New AK: Test AK.")
def test_public(self):
"""
Test handling of public and private events
(only public events should be part of the standard dashboard,
but there should be an individual dashboard for both public and private events)
"""
url_dashboard_index = reverse('dashboard:dashboard')
url_event_dashboard = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
# Non-Public event (should not be part of the global dashboard
# but should have an individual dashboard page for those knowing the url)
self.event.public = False
self.event.save()
response = self.client.get(url_dashboard_index)
self.assertEqual(response.status_code, 200)
self.assertFalse(self.event in response.context["active_and_current_events"])
self.assertFalse(self.event in response.context["old_events"])
response = self.client.get(url_event_dashboard)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["event"], self.event)
# Public event -- should be part of the global dashboard
self.event.public = True
self.event.save()
response = self.client.get(url_dashboard_index)
self.assertEqual(response.status_code, 200)
self.assertTrue(self.event in response.context["active_and_current_events"])
def test_active(self):
"""
Test existence of buttons with regard to activity status of the given event
"""
url_event_dashboard = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
if apps.is_installed('AKSubmission'):
# Non-active event -> No submission
self.event.active = False
self.event.save()
response = self.client.get(url_event_dashboard)
self.assertNotContains(response, "AK Submission")
# Active event -> Submission should be open
self.event.active = True
self.event.save()
response = self.client.get(url_event_dashboard)
self.assertContains(response, "AK Submission")
def test_plan_hidden(self):
"""
Test visibility of plan buttons with regard to plan visibility status for a given event
"""
url_event_dashboard = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
if apps.is_installed('AKPlan'):
# Plan hidden? No buttons should show up
self.event.plan_hidden = True
self.event.save()
response = self.client.get(url_event_dashboard)
self.assertNotContains(response, "Current AKs")
self.assertNotContains(response, "AK Wall")
# Plan not hidden?
# Buttons for current AKs and AK Wall should be on the page
self.event.plan_hidden = False
self.event.save()
response = self.client.get(url_event_dashboard)
self.assertContains(response, "Current AKs")
self.assertContains(response, "AK Wall")
def test_dashboard_buttons(self):
"""
Make sure manually added buttons are displayed correctly
"""
url_event_dashboard = reverse('dashboard:dashboard_event', kwargs={"slug": self.event.slug})
response = self.client.get(url_event_dashboard)
self.assertNotContains(response, "Dashboard Button Test")
DashboardButton.objects.create(
text="Dashboard Button Test",
event=self.event
)
response = self.client.get(url_event_dashboard)
self.assertContains(response, "Dashboard Button Test")
class DashboardViewTests(BasicViewTests, TestCase):
"""
Generic view tests, based on :class:`AKModel.BasicViewTests` as specified in this class in VIEWS
"""
fixtures = ['model.json', 'dashboard.json']
APP_NAME = 'dashboard'
VIEWS = [
('dashboard', {}),
('dashboard_event', {'slug': 'kif42'}),
]
...@@ -5,5 +5,6 @@ from AKDashboard import views ...@@ -5,5 +5,6 @@ from AKDashboard import views
app_name = "dashboard" app_name = "dashboard"
urlpatterns = [ urlpatterns = [
path('', views.TopLevelRedirectView.as_view(), name='top_level_redirect'), path('', views.DashboardView.as_view(), name="dashboard"),
path('<slug:slug>/', views.DashboardEventView.as_view(), name='dashboard_event'),
] ]