Skip to content

Commit

Permalink
Merge branch 'release_2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
octomike committed Sep 11, 2019
2 parents 5109ec5 + 8b40973 commit 1aadd13
Show file tree
Hide file tree
Showing 200 changed files with 2,256 additions and 11,530 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
*.mo
database.db
mails/
.spyderproject
Expand All @@ -17,3 +18,4 @@ media/
scripts/
exports/
backup/
node_modules/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

## command to install dependencies
#install:
# - "pip install -r dependencies.txt"
# - "pip install -r requirements.txt"
# - "pip install flake8"
# - npm install -g casperjs
# # create the database
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ EXPOSE 8000/tcp

ADD . code
WORKDIR code
ENV BUILDPKGS gcc python3-dev libldap2-dev libsasl2-dev libssl-dev
ENV BUILDPKGS gcc python3-dev libldap2-dev libsasl2-dev libssl-dev gettext


RUN apt-get update && apt-get install -y --no-install-recommends $BUILDPKGS
RUN pip install -r dependencies.txt
RUN pip install -r requirements.txt
RUN pip install flake8
RUN cp Lagerregal/template_development.py Lagerregal/settings.py
RUN python manage.py compilemessages -l de
RUN python manage.py migrate
RUN apt-get purge -y $BUILDPKGS

Expand Down
48 changes: 42 additions & 6 deletions Lagerregal/base_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Django settings for Lagerregal project.
from __future__ import unicode_literals
import os


Expand Down Expand Up @@ -50,6 +49,7 @@
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
'npm.finders.NpmFinder',
)

MIDDLEWARE = (
Expand All @@ -63,7 +63,8 @@
# Uncomment the next line for simple clickjacking protection:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'users.middleware.TimezoneMiddleware'
'users.middleware.TimezoneMiddleware',
'users.middleware.LanguageMiddleware',
)

ROOT_URLCONF = 'Lagerregal.urls'
Expand Down Expand Up @@ -92,7 +93,6 @@
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
'builtins': ['permission.templatetags.permissionif']
},
},
]
Expand All @@ -119,7 +119,6 @@
'history',
'reversion',
'rest_framework',
'permission',
'debug_toolbar',
'oauth2_provider',
'django_select2',
Expand Down Expand Up @@ -147,7 +146,7 @@
AUTHENTICATION_BACKENDS = (
# 'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
'permission.backends.PermissionBackend',
'main.backends.LagerregalBackend',
)

# A sample logging configuration. The only tangible logging
Expand Down Expand Up @@ -179,13 +178,50 @@
}
}

NPM_ROOT_PATH = os.getcwd()

NPM_FILE_PATTERNS = {
'bootstrap': [
'dist/js/bootstrap.min.js',
],
'bootswatch': ['*/bootstrap.min.css'],
'font-awesome': [
'css/font-awesome.min.css',
'fonts/*',
],
'jquery': ['dist/jquery.min.js'],
'jquery-ui-dist': [
'jquery-ui.min.js',
'jquery-ui.min.css',
'images/*.png',
],
'datatables': [
'media/css/jquery.dataTables.min.css',
'media/images/*.png',
'media/js/jquery.dataTables.min.js',
],
'mustache': ['mustache.min.js'],
'noty': [
'js/noty/jquery.noty.js',
'js/noty/layouts/*.js',
'js/noty/themes/*.js',
],
'select2': [
'dist/js/select2.min.js',
'dist/css/select2.min.css',
],
'timeago': [
'jquery.timeago.js',
'locales/jquery.timeago.de.js',
],
}

PUBLIC_DEVICES_FILTER = {"tags__id__in": ["3", "17"]}

# get more themes from https://bootswatch.com/ and download them to:
# static/css/themes/<name>.min.css
THEMES = [
'default',
'flatly',
'darkly',
'simplex',
'superhero',
Expand Down
2 changes: 0 additions & 2 deletions Lagerregal/template_development.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from .base_settings import *

DEBUG = True
Expand Down
2 changes: 0 additions & 2 deletions Lagerregal/template_production.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from .base_settings import *

DEBUG = False
Expand Down
281 changes: 136 additions & 145 deletions Lagerregal/urls.py

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions Lagerregal/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import uuid
from datetime import date, timedelta

Expand Down Expand Up @@ -60,4 +58,4 @@ def convert_ad_accountexpires(timestamp):
class DetectableTestRunner(DiscoverRunner):
def __init__(self, *args, **kwargs):
settings.TEST_MODE = True
super(DetectableTestRunner, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
1 change: 0 additions & 1 deletion Lagerregal/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
framework.
"""
from __future__ import unicode_literals

import os
import sys
Expand Down
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
VIRTUAL_ENV ?= .venv

.PHONY: run
run: $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/pip install -r requirements.txt
yarn install || npm install
cp -n Lagerregal/template_development.py Lagerregal/settings.py
$(VIRTUAL_ENV)/bin/python manage.py compilemessages -l de
$(VIRTUAL_ENV)/bin/python manage.py migrate
$(VIRTUAL_ENV)/bin/python manage.py populate
$(VIRTUAL_ENV)/bin/python manage.py runserver

.PHONY: makemessages
makemessages: $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/python manage.py makemessages -l de -d django --ignore=node_modules
$(VIRTUAL_ENV)/bin/python manage.py makemessages -l de -d djangojs --ignore=node_modules

.PHONY: test
test: $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/pip install coverage
$(VIRTUAL_ENV)/bin/coverage run --branch --omit=.venv/* manage.py test
$(VIRTUAL_ENV)/bin/coverage html --skip-covered

.PHONY: lint
lint: $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/pip install flake8 isort
$(VIRTUAL_ENV)/bin/flake8
$(VIRTUAL_ENV)/bin/isort -rc -c api demo devicegroups devices devicetags history Lagerregal locale locations mail main media netork users

$(VIRTUAL_ENV):
python3 -m venv $(VIRTUAL_ENV)
$(VIRTUAL_ENV)/bin/pip install -U pip
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Manual Quickstart
Install necessary requirements (either globally or with virtualenv)

```
$ pip install -U -r dependencies.txt
$ pip install -U -r requirements.txt
$ npm install
```

Generate settings.py
Expand All @@ -63,6 +64,11 @@ For production (edit first):
$ cp Lagerregal/template_production.py Lagerregal/settings.py
```

Compile translations:
```
$ python manage.py compilemessages -l de
```

Run:

```
Expand Down
1 change: 0 additions & 1 deletion api/models.py

This file was deleted.

6 changes: 2 additions & 4 deletions api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from rest_framework import serializers
from django.contrib.auth.models import Group, Permission

Expand Down Expand Up @@ -143,14 +141,14 @@ def restore_object(self, attrs, instance=None):
if self.context["request"].POST:
del attrs["room"]
del self.fields["room"]
obj = super(LendingSerializer, self).restore_object(attrs, instance=instance)
obj = super().restore_object(attrs, instance=instance)
return obj

def to_native(self, obj):
if self.context["request"].POST:
if "room" in self.fields:
del self.fields["room"]
return super(LendingSerializer, self).to_native(obj)
return super().to_native(obj)


class UserSerializer(serializers.HyperlinkedModelSerializer):
Expand Down
17 changes: 0 additions & 17 deletions api/tests.py

This file was deleted.

10 changes: 4 additions & 6 deletions api/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import datetime

from rest_framework import generics
Expand Down Expand Up @@ -70,9 +68,9 @@ class DeviceApiDetail(generics.RetrieveUpdateDestroyAPIView):

def get_object(self, query=None):
if query:
device = super(DeviceApiDetail, self).get_object(query)
device = super().get_object(query)
else:
device = super(DeviceApiDetail, self).get_object()
device = super().get_object()
device.bookmarked = device.bookmarkers.filter(id=self.request.user.id).exists()
return device

Expand All @@ -86,7 +84,7 @@ def post(self, request, pk):
return self.put(request, pk)

def put(self, request, pk, **kwargs):
response = super(DeviceApiRoomChange, self).put(request, pk)
response = super().put(request, pk)
try:
template = MailTemplate.objects.get(usage="room")
except:
Expand Down Expand Up @@ -147,7 +145,7 @@ def post(self, request, *args, **kwargs):
room = None
else:
room = None
response = super(DeviceApiLend, self).post(request)
response = super().post(request)
if request.POST["device"] != "" and response.status_code == 201:
device = Device.objects.get(pk=request.POST["device"])
device.currentlending = self.object
Expand Down
3 changes: 0 additions & 3 deletions devicegroups/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
8 changes: 1 addition & 7 deletions devicegroups/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from __future__ import unicode_literals

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.urls import reverse

import six
from reversion import revisions as reversion

from users.models import Department


@six.python_2_unicode_compatible
@reversion.register()
class Devicegroup(models.Model):
name = models.CharField(max_length=200)
department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE)
Expand All @@ -30,6 +27,3 @@ def get_absolute_url(self):

def get_edit_url(self):
return reverse('devicegroup-edit', kwargs={'pk': self.pk})


reversion.register(Devicegroup)
28 changes: 24 additions & 4 deletions devicegroups/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from __future__ import unicode_literals

from django.test.client import Client
from django.test import TestCase
from django.urls import reverse

import six
from model_mommy import mommy

from devicegroups.models import Devicegroup
Expand All @@ -19,6 +16,29 @@ def setUp(self):

def test_devicegroup_creation(self):
devicegroup = mommy.make(Devicegroup)
self.assertEqual(six.text_type(devicegroup), devicegroup.name)
self.assertEqual(str(devicegroup), devicegroup.name)
self.assertEqual(devicegroup.get_absolute_url(), reverse('devicegroup-detail', kwargs={'pk': devicegroup.pk}))
self.assertEqual(devicegroup.get_edit_url(), reverse('devicegroup-edit', kwargs={'pk': devicegroup.pk}))

def test_list_view(self):
response = self.client.get('/devicegroups/')
self.assertEqual(response.status_code, 200)

def test_create_view(self):
response = self.client.get('/devicegroups/add')
self.assertEqual(response.status_code, 200)

def test_detail_view(self):
devicegroup = mommy.make(Devicegroup)
response = self.client.get('/devicegroups/view/%i' % devicegroup.pk)
self.assertEqual(response.status_code, 200)

def test_update_view(self):
devicegroup = mommy.make(Devicegroup)
response = self.client.get('/devicegroups/edit/%i' % devicegroup.pk)
self.assertEqual(response.status_code, 200)

def test_delete_view(self):
devicegroup = mommy.make(Devicegroup)
response = self.client.get('/devicegroups/delete/%i' % devicegroup.pk)
self.assertEqual(response.status_code, 200)
Loading

0 comments on commit 1aadd13

Please sign in to comment.