Add api and audit structure

This commit is contained in:
Jens Langhammer 2018-11-23 17:05:41 +01:00
parent 00cf64ef31
commit d0a7bf5ecc
14 changed files with 86 additions and 0 deletions

2
passbook/api/__init__.py Normal file
View file

@ -0,0 +1,2 @@
"""passbook api"""
default_app_config = 'passbook.api.apps.PassbookAPIConfig'

10
passbook/api/apps.py Normal file
View file

@ -0,0 +1,10 @@
"""passbook API AppConfig"""
from django.apps import AppConfig
class PassbookAPIConfig(AppConfig):
"""passbook API Config"""
name = 'passbook.api'
label = 'passbook_api'
mountpoint = 'api/'

3
passbook/api/urls.py Normal file
View file

@ -0,0 +1,3 @@
"""passbook api urls"""
urlpatterns = []

View file

View file

0
passbook/api/v1/urls.py Normal file
View file

1
passbook/api/v1/views.py Normal file
View file

@ -0,0 +1 @@
from rest_framework.viewsets import ViewSet

View file

@ -0,0 +1,3 @@
"""passbook audit Header"""
__version__ = '0.0.1-alpha'
default_app_config = 'passbook.audit.apps.PassbookAuditConfig'

10
passbook/audit/apps.py Normal file
View file

@ -0,0 +1,10 @@
"""passbook audit app"""
from django.apps import AppConfig
class PassbookAuditConfig(AppConfig):
"""passbook audit app"""
name = 'passbook.audit'
label = 'passbook_audit'
mountpoint = 'audit/'

View file

@ -0,0 +1,32 @@
# Generated by Django 2.1.3 on 2018-11-22 10:03
import uuid
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='AuditEntry',
fields=[
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('action', models.TextField()),
('date', models.DateTimeField(auto_now_add=True)),
('app', models.TextField()),
('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]

View file

22
passbook/audit/models.py Normal file
View file

@ -0,0 +1,22 @@
"""passbook audit models"""
from django.conf import settings
from django.db import models
from reversion import register
from passbook.lib.models import UUIDModel
@register()
class AuditEntry(UUIDModel):
"""An individual audit log entry"""
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL)
action = models.TextField()
date = models.DateTimeField(auto_now_add=True)
app = models.TextField()
def save(self, *args, **kwargs):
if self.pk:
raise NotImplementedError("you may not edit an existing %s" % self._meta.model_name)
super().save(*args, **kwargs)

2
passbook/audit/urls.py Normal file
View file

@ -0,0 +1,2 @@
"""passbook audit urls"""
urlpatterns = []

View file

@ -59,6 +59,7 @@ INSTALLED_APPS = [
'crispy_forms', 'crispy_forms',
'passbook.core', 'passbook.core',
'passbook.admin', 'passbook.admin',
'passbook.api',
'passbook.audit', 'passbook.audit',
'passbook.lib', 'passbook.lib',
'passbook.ldap', 'passbook.ldap',