Skip to content
Snippets Groups Projects
Commit f7172e71 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'deb-issues' into 'master'

Deb issues

Closes #367, #366, and #365

See merge request NCER-PD/scheduling-system!302
parents 4eaf6946 ec38df99
No related branches found
No related tags found
1 merge request!302Deb issues
Pipeline #36854 passed
smasch (1.0.0~beta.4-1) unstable; urgency=low
* bug fix: MEDIA_ROOT was overwritten by tests that messed up with
deployment sometimes (#365)
* bug fix: media files were not served in production (#366)
* bug fix: crontab was cleared after debian package updated (#367)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 26 Jan 2021 16:00:00 +0200
smasch (1.0.0~beta.3-1) unstable; urgency=low smasch (1.0.0~beta.3-1) unstable; urgency=low
* bug fix: upgrade from 0.15 version containing subjects failed * bug fix: upgrade from 0.15 version containing subjects failed
......
...@@ -50,9 +50,7 @@ if [ -d /run/systemd/system ]; then ...@@ -50,9 +50,7 @@ if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true systemctl --system daemon-reload >/dev/null || true
fi fi
if [ "$1" = "configure" ] && [ -z "$2" ]; then crontab -u smasch -l 2>/dev/null | grep -v "runcrons" | { cat; echo "*/5 * * * * . /usr/lib/smasch/env/bin/activate && python /usr/lib/smasch/manage.py runcrons >> /var/log/smasch/cronjob.log 2>&1"; } | crontab -u smasch -
crontab -u smasch -l 2>/dev/null | grep -v "runcrons" | { cat; echo "*/5 * * * * . /usr/lib/smasch/env/bin/activate && python /usr/lib/smasch/manage.py runcrons >> /var/log/smasch/cronjob.log 2>&1"; } | crontab -u smasch -
fi
#DEBHELPER# #DEBHELPER#
...@@ -13,20 +13,25 @@ Including another URLconf ...@@ -13,20 +13,25 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include 1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
""" """
import re
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import url, include
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.urls import re_path
from django.views.static import serve
from two_factor.urls import urlpatterns as tf_urls from two_factor.urls import urlpatterns as tf_urls
from web import api_urls from web import api_urls
from web import urls from web import urls
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'', include(urls)), url(r'', include(urls)),
url(r'^api/', include(api_urls)), url(r'^api/', include(api_urls)),
url(r'', include(tf_urls)), url(r'', include(tf_urls))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ]
if settings.SERVE_STATIC or settings.DEBUG:
urlpatterns.append(re_path(r'^%s(?P<path>.*)$' % re.escape(settings.MEDIA_URL.lstrip('/')), serve,
{'document_root': settings.MEDIA_ROOT}))
...@@ -256,7 +256,7 @@ desired effect ...@@ -256,7 +256,7 @@ desired effect
{% block footer %} {% block footer %}
<!-- To the right --> <!-- To the right -->
<div class="pull-right hidden-xs"> <div class="pull-right hidden-xs">
Version: <strong>1.0.0~beta.3</strong> Version: <strong>1.0.0~beta.4</strong>
</div> </div>
<!-- Default to the left --> <!-- Default to the left -->
......
import logging import logging
import os import os
import sys
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.test import Client from django.test import Client
from django.test import TestCase from django.test import TestCase
from web.models import Worker
from web.decorators import PermissionDecorator
from web.decorators import PermissionDecorator
from web.models import Worker
from .functions import create_worker, create_user, add_permissions_to_worker from .functions import create_worker, create_user, add_permissions_to_worker
settings.MEDIA_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') # if manage.py test was called, use test settings
if 'test' in sys.argv:
try:
settings.MEDIA_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
except ImportError:
pass
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -19,7 +26,7 @@ class LoggedInTestCase(TestCase): ...@@ -19,7 +26,7 @@ class LoggedInTestCase(TestCase):
self.password = 'abcd1234' self.password = 'abcd1234'
#superuser #superuser
self.super_worker = create_worker(user=User.objects.create_superuser(username='super', password=self.password, email='a@mail.com')) self.super_worker = create_worker(user=User.objects.create_superuser(username='super', password=self.password, email='a@mail.com'))
#admin #admin
self.admin_worker = Worker.get_by_user(create_user(username='admin', password=self.password)) self.admin_worker = Worker.get_by_user(create_user(username='admin', password=self.password))
add_permissions_to_worker(self.admin_worker, PermissionDecorator.codenames) add_permissions_to_worker(self.admin_worker, PermissionDecorator.codenames)
#staff #staff
...@@ -34,15 +41,15 @@ class LoggedInTestCase(TestCase): ...@@ -34,15 +41,15 @@ class LoggedInTestCase(TestCase):
def login_as_staff(self): def login_as_staff(self):
self.client.logout() self.client.logout()
self.client.login(username='staff', password=self.password) self.client.login(username='staff', password=self.password)
def login_as_admin(self): def login_as_admin(self):
self.client.logout() self.client.logout()
self.client.login(username='admin', password=self.password) self.client.login(username='admin', password=self.password)
def login_as_super(self): def login_as_super(self):
self.client.logout() self.client.logout()
self.client.login(username='super', password=self.password) self.client.login(username='super', password=self.password)
class LoggedInWithWorkerTestCase(LoggedInTestCase): class LoggedInWithWorkerTestCase(LoggedInTestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment