mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
feat: add the new reminders app
This commit is contained in:
parent
27db4f7e51
commit
b876a0d0df
@ -10,3 +10,14 @@ td a.tag {
|
||||
margin: 1px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#result_list th.column-note {
|
||||
text-align: right;
|
||||
}
|
||||
#result_list td.field-note {
|
||||
text-align: right;
|
||||
}
|
||||
#result_list td textarea {
|
||||
width: 90%;
|
||||
height: 5em;
|
||||
}
|
@ -61,6 +61,7 @@ INSTALLED_APPS = [
|
||||
"django_extensions",
|
||||
|
||||
"documents.apps.DocumentsConfig",
|
||||
"reminders.apps.RemindersConfig",
|
||||
"paperless_tesseract.apps.PaperlessTesseractConfig",
|
||||
|
||||
"flat_responsive",
|
||||
|
@ -24,11 +24,13 @@ from documents.views import (
|
||||
IndexView, FetchView, PushView,
|
||||
CorrespondentViewSet, TagViewSet, DocumentViewSet, LogViewSet
|
||||
)
|
||||
from reminders.views import ReminderViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r"correspondents", CorrespondentViewSet)
|
||||
router.register(r"documents", DocumentViewSet)
|
||||
router.register(r"logs", LogViewSet)
|
||||
router.register(r"reminders", ReminderViewSet)
|
||||
router.register(r"tags", TagViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
|
0
src/reminders/__init__.py
Normal file
0
src/reminders/__init__.py
Normal file
20
src/reminders/admin.py
Normal file
20
src/reminders/admin.py
Normal file
@ -0,0 +1,20 @@
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Reminder
|
||||
|
||||
|
||||
class ReminderAdmin(admin.ModelAdmin):
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
"all": ("paperless.css",)
|
||||
}
|
||||
|
||||
list_per_page = settings.PAPERLESS_LIST_PER_PAGE
|
||||
list_display = ("date", "document", "note")
|
||||
list_filter = ("date",)
|
||||
list_editable = ("note",)
|
||||
|
||||
|
||||
admin.site.register(Reminder, ReminderAdmin)
|
5
src/reminders/apps.py
Normal file
5
src/reminders/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class RemindersConfig(AppConfig):
|
||||
name = "reminders"
|
14
src/reminders/filters.py
Normal file
14
src/reminders/filters.py
Normal file
@ -0,0 +1,14 @@
|
||||
from django_filters.rest_framework import CharFilter, FilterSet
|
||||
|
||||
from .models import Reminder
|
||||
|
||||
|
||||
class ReminderFilterSet(FilterSet):
|
||||
|
||||
class Meta(object):
|
||||
model = Reminder
|
||||
fields = {
|
||||
"document": ["exact"],
|
||||
"date": ["gt", "lt", "gte", "lte", "exact"],
|
||||
"note": ["istartswith", "iendswith", "icontains"]
|
||||
}
|
27
src/reminders/migrations/0001_initial.py
Normal file
27
src/reminders/migrations/0001_initial.py
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-03-25 15:58
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('documents', '0016_auto_20170325_1558'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Reminder',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('date', models.DateTimeField()),
|
||||
('note', models.TextField(blank=True)),
|
||||
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='documents.Document')),
|
||||
],
|
||||
),
|
||||
]
|
0
src/reminders/migrations/__init__.py
Normal file
0
src/reminders/migrations/__init__.py
Normal file
8
src/reminders/models.py
Normal file
8
src/reminders/models.py
Normal file
@ -0,0 +1,8 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Reminder(models.Model):
|
||||
|
||||
document = models.ForeignKey("documents.Document")
|
||||
date = models.DateTimeField()
|
||||
note = models.TextField(blank=True)
|
14
src/reminders/serialisers.py
Normal file
14
src/reminders/serialisers.py
Normal file
@ -0,0 +1,14 @@
|
||||
from documents.models import Document
|
||||
from rest_framework import serializers
|
||||
|
||||
from .models import Reminder
|
||||
|
||||
|
||||
class ReminderSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
document = serializers.HyperlinkedRelatedField(
|
||||
view_name="drf:document-detail", queryset=Document.objects)
|
||||
|
||||
class Meta(object):
|
||||
model = Reminder
|
||||
fields = ("id", "document", "date", "note")
|
3
src/reminders/tests.py
Normal file
3
src/reminders/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
22
src/reminders/views.py
Normal file
22
src/reminders/views.py
Normal file
@ -0,0 +1,22 @@
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from rest_framework.filters import OrderingFilter
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.viewsets import (
|
||||
ModelViewSet,
|
||||
)
|
||||
|
||||
from .filters import ReminderFilterSet
|
||||
from .models import Reminder
|
||||
from .serialisers import ReminderSerializer
|
||||
from paperless.views import StandardPagination
|
||||
|
||||
|
||||
class ReminderViewSet(ModelViewSet):
|
||||
model = Reminder
|
||||
queryset = Reminder.objects
|
||||
serializer_class = ReminderSerializer
|
||||
pagination_class = StandardPagination
|
||||
permission_classes = (IsAuthenticated,)
|
||||
filter_backends = (DjangoFilterBackend, OrderingFilter)
|
||||
filter_class = ReminderFilterSet
|
||||
ordering_fields = ("date", "document")
|
Loading…
x
Reference in New Issue
Block a user