Add api and audit structure
This commit is contained in:
		
							
								
								
									
										2
									
								
								passbook/api/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								passbook/api/__init__.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
"""passbook api"""
 | 
			
		||||
default_app_config = 'passbook.api.apps.PassbookAPIConfig'
 | 
			
		||||
							
								
								
									
										10
									
								
								passbook/api/apps.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								passbook/api/apps.py
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										3
									
								
								passbook/api/urls.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
"""passbook api urls"""
 | 
			
		||||
 | 
			
		||||
urlpatterns = []
 | 
			
		||||
							
								
								
									
										0
									
								
								passbook/api/v1/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								passbook/api/v1/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								passbook/api/v1/serializers.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								passbook/api/v1/serializers.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								passbook/api/v1/urls.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								passbook/api/v1/urls.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								passbook/api/v1/views.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								passbook/api/v1/views.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
from rest_framework.viewsets import ViewSet
 | 
			
		||||
							
								
								
									
										3
									
								
								passbook/audit/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								passbook/audit/__init__.py
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										10
									
								
								passbook/audit/apps.py
									
									
									
									
									
										Normal 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/'
 | 
			
		||||
							
								
								
									
										32
									
								
								passbook/audit/migrations/0001_initial.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								passbook/audit/migrations/0001_initial.py
									
									
									
									
									
										Normal 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,
 | 
			
		||||
            },
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
							
								
								
									
										0
									
								
								passbook/audit/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								passbook/audit/migrations/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										22
									
								
								passbook/audit/models.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								passbook/audit/models.py
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										2
									
								
								passbook/audit/urls.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
"""passbook audit urls"""
 | 
			
		||||
urlpatterns = []
 | 
			
		||||
@ -59,6 +59,7 @@ INSTALLED_APPS = [
 | 
			
		||||
    'crispy_forms',
 | 
			
		||||
    'passbook.core',
 | 
			
		||||
    'passbook.admin',
 | 
			
		||||
    'passbook.api',
 | 
			
		||||
    'passbook.audit',
 | 
			
		||||
    'passbook.lib',
 | 
			
		||||
    'passbook.ldap',
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user