Commit 73528fb6 authored by Calum Mackervoy's avatar Calum Mackervoy

removed MetaMixin

parent bc23913a
Pipeline #7298 failed with stage
in 1 minute and 14 seconds
......@@ -152,17 +152,6 @@ $ python3 manage.py runserver
To use DjangoLDP in your models you just need to extend djangoldp.Model
It is recommended to also extend the Model's Meta class from LDPMetaMixin to inherit default settings, notably the default_permissions defined in the [Solid ACLs spec](https://github.com/solid/web-access-control-spec)
```python
from djangoldp.models import Model, LDPMetaMixin
class Todo(Model):
name = models.CharField(max_length=255)
class Meta(LDPMetaMixin):
```
See "Custom Meta options" below to see some helpful ways you can tweak the behaviour of DjangoLDP
Your model will be automatically detected and registered with an LDPViewSet and corresponding URLs, as well as being registered with the Django admin panel. If you register your model with the admin panel manually, make sure to extend the GuardedModelAdmin so that the model is registered with [Django-Guardian object permissions](https://django-guardian.readthedocs.io/en/stable/userguide/admin-integration.html)
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2020-02-21 11:18
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('djangoldp', '0003_auto_20190911_0931'),
]
operations = [
migrations.AlterModelOptions(
name='ldpsource',
options={'ordering': ('federation',)},
),
]
......@@ -13,11 +13,6 @@ from djangoldp.fields import LDPUrlField
from djangoldp.permissions import LDPPermissions
class LDPPMetaMixin:
'''A meta class which all children of Model should inherit'''
default_permissions = ('add', 'change', 'delete', 'view', 'control')
class Model(models.Model):
urlid = LDPUrlField(blank=True, null=True, unique=True)
......@@ -94,7 +89,8 @@ class Model(models.Model):
return path
class Meta(LDPPMetaMixin):
class Meta:
default_permissions = ('add', 'change', 'delete', 'view', 'control')
abstract = True
depth = 0
......@@ -169,7 +165,7 @@ class Model(models.Model):
class LDPSource(Model):
federation = models.CharField(max_length=255)
class Meta(LDPPMetaMixin):
class Meta:
rdf_type = 'ldp:Container'
ordering = ('federation',)
container_path = 'sources'
......
......@@ -3,7 +3,7 @@ from django.contrib.auth import get_user_model
from django.db import models
from django.utils.datetime_safe import date
from djangoldp.models import Model, LDPPMetaMixin
from djangoldp.models import Model
class Skill(Model):
......@@ -15,7 +15,7 @@ class Skill(Model):
def recent_jobs(self):
return self.joboffer_set.filter(date__gte=date.today())
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'delete', 'control']
......@@ -35,7 +35,7 @@ class JobOffer(Model):
def some_skill(self):
return self.skills.all().first()
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'change', 'add']
owner_perms = ['inherit', 'delete', 'control']
......@@ -50,7 +50,7 @@ class Conversation(models.Model):
author_user = models.ForeignKey(settings.AUTH_USER_MODEL)
peer_user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name="peers_conv")
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'delete', 'control']
......@@ -60,7 +60,7 @@ class Resource(Model):
joboffers = models.ManyToManyField(JobOffer, blank=True, related_name='resources')
description = models.CharField(max_length=255)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view', 'add', 'delete', 'change', 'control']
authenticated_perms = ['inherit']
owner_perms = ['inherit']
......@@ -73,7 +73,7 @@ class UserProfile(Model):
description = models.CharField(max_length=255, blank=True, null=True)
user = models.OneToOneField(settings.AUTH_USER_MODEL)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit']
owner_perms = ['inherit', 'change', 'control']
......@@ -85,7 +85,7 @@ class Message(models.Model):
conversation = models.ForeignKey(Conversation, on_delete=models.DO_NOTHING)
author_user = models.ForeignKey(settings.AUTH_USER_MODEL)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'delete', 'control']
......@@ -95,7 +95,7 @@ class Dummy(models.Model):
some = models.CharField(max_length=255, blank=True, null=True)
slug = models.SlugField(blank=True, null=True, unique=True)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'delete', 'control']
......@@ -104,7 +104,7 @@ class Dummy(models.Model):
class LDPDummy(Model):
some = models.CharField(max_length=255, blank=True, null=True)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
owner_perms = ['inherit', 'change', 'delete', 'control']
......@@ -115,7 +115,7 @@ class PermissionlessDummy(Model):
some = models.CharField(max_length=255, blank=True, null=True)
slug = models.SlugField(blank=True, null=True, unique=True)
class Meta(LDPPMetaMixin):
class Meta:
anonymous_perms = []
authenticated_perms = []
owner_perms = []
......@@ -125,7 +125,7 @@ class Invoice(Model):
title = models.CharField(max_length=255, blank=True, null=True)
date = models.DateField(blank=True, null=True)
class Meta(LDPPMetaMixin):
class Meta:
depth = 2
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
......@@ -137,7 +137,7 @@ class Batch(Model):
invoice = models.ForeignKey(Invoice, on_delete=models.CASCADE, related_name='batches')
title = models.CharField(max_length=255, blank=True, null=True)
class Meta(LDPPMetaMixin):
class Meta:
serializer_fields = ['@id', 'title', 'invoice', 'tasks']
anonymous_perms = ['view', 'add']
authenticated_perms = ['inherit', 'add']
......@@ -150,7 +150,7 @@ class Task(models.Model):
batch = models.ForeignKey(Batch, on_delete=models.CASCADE, related_name='tasks')
title = models.CharField(max_length=255)
class Meta(LDPPMetaMixin):
class Meta:
serializer_fields = ['@id', 'title', 'batch']
anonymous_perms = ['view']
authenticated_perms = ['inherit', 'add']
......@@ -162,7 +162,7 @@ class Post(Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True)
peer_user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True, null=True, related_name="peers_post")
class Meta(LDPPMetaMixin):
class Meta:
auto_author = 'author'
anonymous_perms = ['view', 'add', 'delete', 'add', 'change', 'control']
authenticated_perms = ['inherit']
......@@ -173,7 +173,7 @@ class Circle(Model):
description = models.CharField(max_length=255)
team = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)
class Meta(LDPPMetaMixin):
class Meta:
nested_fields = ["team"]
anonymous_perms = ['view', 'add', 'delete', 'add', 'change', 'control']
authenticated_perms = ["inherit"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment