Browse Source

Restructure gvaweb to correct package paths

master
Jan Dittberner 2 years ago
parent
commit
0eb766051c
  1. 1
      .gitignore
  2. 1
      docs/install.rst
  3. 0
      gvacommon/.gitignore
  4. 0
      gvacommon/__init__.py
  5. 4
      gvacommon/celeryrouters.py
  6. 4
      gvaweb/__init__.py
  7. 42
      gvaweb/gvacommon/viewmixins.py
  8. 0
      gvaweb/gvaweb/__init__.py
  9. 1
      gvaweb/settings.py
  10. 4
      gvaweb/webtasks/tasks.py

1
.gitignore

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

1
docs/install.rst

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

0
gvaweb/gvacommon/.gitignore → gvacommon/.gitignore

0
gvaweb/gvacommon/__init__.py → gvacommon/__init__.py

4
gvaweb/gvacommon/celeryrouters.py → gvacommon/celeryrouters.py

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

4
gvaweb/gvaweb/celery.py → gvaweb/__init__.py

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

42
gvaweb/gvacommon/viewmixins.py

@ -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")

0
gvaweb/gvaweb/__init__.py

1
gvaweb/gvaweb/settings.py → gvaweb/settings.py

@ -42,6 +42,5 @@ BROKER_URL = get_env_setting('GVAWEB_BROKER_URL')
########## GVAWEB CONFIGURATION
GVAWEB_NGINX_SITES_AVAILABLE = get_env_setting('GVAWEB_NGINX_SITES_AVAILABLE')
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')
########## END GVAWEB CONFIGURATION

4
gvaweb/webtasks/tasks.py

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

Loading…
Cancel
Save