Restructure gvaweb to correct package paths

This commit is contained in:
Jan Dittberner 2020-03-02 16:51:00 +01:00
parent 63e065b8c0
commit 0eb766051c
10 changed files with 3 additions and 54 deletions

1
.gitignore vendored
View file

@ -43,3 +43,4 @@ _build/
*.sqlite3 *.sqlite3
.idea/ .idea/
.vagrant/ .vagrant/
.env

View file

@ -30,7 +30,6 @@ into the gvaweb directory and run the celery worker with:
.. code-block:: sh .. code-block:: sh
$ cd gvaweb
$ pipenv run celery -A gvaweb worker -Q web -l info $ pipenv run celery -A gvaweb worker -Q web -l info
.. _Celery: http://www.celeryproject.org/ .. _Celery: http://www.celeryproject.org/

View file

@ -1,9 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
class GvaRouter(object): class GvaRouter(object):
def route_for_task(self, task, args=None, kwargs=None): def route_for_task(self, task, args=None, kwargs=None):
for route in ['ldap', 'file', 'mysql', 'pgsql', 'web']: for route in ['ldap', 'file', 'mysql', 'pgsql', 'web']:
if route in task: if route in task:

View file

@ -4,12 +4,10 @@ This module defines the Celery_ app for gvaweb.
.. _Celery: http://www.celeryproject.org/ .. _Celery: http://www.celeryproject.org/
""" """
from __future__ import absolute_import
from celery import Celery from celery import Celery
#: The Celery application #: The Celery application
app = Celery('gvaweb') app = Celery('gvaweb')
app.config_from_object('gvaweb.settings') app.config_from_object('gvaweb.settings')
app.autodiscover_tasks(['webtasks'], force=True) app.autodiscover_tasks(['gvaweb.webtasks'], force=True)

View file

@ -1,42 +0,0 @@
"""
This module defines mixins for gnuviechadmin views.
"""
from __future__ import unicode_literals
from django.http import HttpResponseForbidden
from django.utils.translation import ugettext as _
from braces.views import LoginRequiredMixin
class StaffOrSelfLoginRequiredMixin(LoginRequiredMixin):
"""
Mixin that makes sure that a user is logged in and matches the current
customer or is a staff user.
"""
def dispatch(self, request, *args, **kwargs):
if (
request.user.is_staff or
request.user == self.get_customer_object()
):
return super(StaffOrSelfLoginRequiredMixin, self).dispatch(
request, *args, **kwargs
)
return HttpResponseForbidden(
_('You are not allowed to view this page.')
)
def get_customer_object(self):
"""
Views based on this mixin have to implement this method to return
the customer that must be an object of the same class as the
django.contrib.auth user type.
:return: customer
:rtype: settings.AUTH_USER_MODEL
"""
raise NotImplemented("subclass has to implement get_customer_object")

View file

@ -42,6 +42,5 @@ BROKER_URL = get_env_setting('GVAWEB_BROKER_URL')
########## GVAWEB CONFIGURATION ########## GVAWEB CONFIGURATION
GVAWEB_NGINX_SITES_AVAILABLE = get_env_setting('GVAWEB_NGINX_SITES_AVAILABLE') GVAWEB_NGINX_SITES_AVAILABLE = get_env_setting('GVAWEB_NGINX_SITES_AVAILABLE')
GVAWEB_NGINX_SITES_ENABLED = get_env_setting('GVAWEB_NGINX_SITES_ENABLED') GVAWEB_NGINX_SITES_ENABLED = get_env_setting('GVAWEB_NGINX_SITES_ENABLED')
GVAWEB_PHPFPM_POOL = get_env_setting('GVAWEB_PHPFPM_POOL')
GVAWEB_WWWUSER_MOUNT = get_env_setting('GVAWEB_WWWUSER_MOUNT') GVAWEB_WWWUSER_MOUNT = get_env_setting('GVAWEB_WWWUSER_MOUNT')
########## END GVAWEB CONFIGURATION ########## END GVAWEB CONFIGURATION

View file

@ -2,8 +2,6 @@
This module defines Celery_ tasks to manage website configurations. This module defines Celery_ tasks to manage website configurations.
""" """
from __future__ import absolute_import
import os import os
import subprocess import subprocess
from tempfile import mkstemp from tempfile import mkstemp
@ -24,7 +22,7 @@ LN_CMD = '/bin/ln'
SERVICE_CMD = '/bin/systemctl' SERVICE_CMD = '/bin/systemctl'
INSTALL_CMD = '/usr/bin/install' INSTALL_CMD = '/usr/bin/install'
JINJAENV = Environment(loader=PackageLoader('webtasks', 'templates')) JINJAENV = Environment(loader=PackageLoader('gvaweb.webtasks', 'templates'))
def _jinja_parentdomain(domain): def _jinja_parentdomain(domain):