diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb5e0a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +__pycache__/* +db.sqlite3 +*.pyc +*.egg-info +dist +script \ No newline at end of file diff --git a/README.md b/README.md index dc2e04a..316c6e2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ -# Djangoldp Notifications +# Synopsis +This module is an add-on for Django REST Framework, based on Django LDP add-on. It serves django models for a notifications component, respecting the Linked Data Platform convention. +It aims at enabling people with little development skills to serve their own data, to be used with a LDP application. +# Models +## Notification +A object representing a notification \ No newline at end of file diff --git a/djangoldp_notifications/__init__.py b/djangoldp_notifications/__init__.py new file mode 100644 index 0000000..8f85b58 --- /dev/null +++ b/djangoldp_notifications/__init__.py @@ -0,0 +1 @@ +name = "djangoldp_notifications" \ No newline at end of file diff --git a/djangoldp_notifications/admin.py b/djangoldp_notifications/admin.py new file mode 100644 index 0000000..783f0f0 --- /dev/null +++ b/djangoldp_notifications/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Notification + +admin.site.register(Notification) diff --git a/djangoldp_notifications/apps.py b/djangoldp_notifications/apps.py new file mode 100644 index 0000000..014d0a3 --- /dev/null +++ b/djangoldp_notifications/apps.py @@ -0,0 +1,4 @@ +from django.apps import AppConfig + +class DjangoldpNotificationsConfig(AppConfig): + name = 'djangoldp_notifications' diff --git a/djangoldp_notifications/migrations/0001_initial.py b/djangoldp_notifications/migrations/0001_initial.py new file mode 100644 index 0000000..b74b1b8 --- /dev/null +++ b/djangoldp_notifications/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2019-01-08 08:32 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Notification', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('object', models.URLField()), + ('type', models.CharField(max_length=255)), + ('summary', models.TextField()), + ('date', models.DateTimeField(auto_now_add=True)), + ('read', models.BooleanField()), + ('author_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='author', to=settings.AUTH_USER_MODEL)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'ordering': ['date'], + 'permissions': (('view_notification', 'Read'), ('control_notification', 'Control')), + }, + ), + ] \ No newline at end of file diff --git a/djangoldp_notifications/migrations/__init__.py b/djangoldp_notifications/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djangoldp_notifications/models.py b/djangoldp_notifications/models.py new file mode 100644 index 0000000..2ed3722 --- /dev/null +++ b/djangoldp_notifications/models.py @@ -0,0 +1,22 @@ +from django.db import models +from django.conf import settings +from django.contrib.auth.models import User + +class Notification(models.Model): + user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='user') + author_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='author') + object = models.URLField() + type = models.CharField(max_length=255) + summary = models.TextField() + date = models.DateTimeField(auto_now_add=True) + read = models.BooleanField() + class Meta: + permissions = ( + ('view_notification', 'Read'), + ('control_notification', 'Control'), + ) + auto_author = 'author_user' + ordering = ['date'] + + def __str__(self): + return '{}'.format(self.type) diff --git a/djangoldp_notifications/urls.py b/djangoldp_notifications/urls.py new file mode 100644 index 0000000..bc15376 --- /dev/null +++ b/djangoldp_notifications/urls.py @@ -0,0 +1,9 @@ +"""djangoldp_notifications URL Configuration""" +from django.conf.urls import url +from .models import Notification +from djangoldp.views import LDPViewSet + + +urlpatterns = [ + url(r'^notifications/', LDPViewSet.urls(model=Notification)), +] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..18760ef --- /dev/null +++ b/setup.py @@ -0,0 +1,15 @@ +import os +from setuptools import setup, find_packages + +# allow setup.py to be run from any path +os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) + +setup(name='djangoldp_notifications', + version='0.0.1', + description='djangoldp package for notifications data models', + url='https://git.happy-dev.fr/startinblox/djangoldp-packages/djangoldp-notifications', + author="Startin'blox", + author_email='matthieu@happy-dev.fr', + license='MIT', + packages=find_packages(), + zip_safe=False)