1 # chloro - personal space
2 # Copyright (C) 2019 Frederic Peters
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published
6 # by the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 from django.http import Http404
18 from django.views.generic import CreateView, DeleteView, DetailView, UpdateView, TemplateView
20 from .models import Note
23 class NoteView(DetailView):
26 def get(self, request, *args, **kwargs):
27 if kwargs.get('year'):
28 # check date does match
29 note = self.get_object()
30 creation = self.get_object().creation_timestamp
31 if (creation.year, creation.month, creation.day) != (
37 return super(NoteView, self).get(request, *args, **kwargs)
40 class NoteEditView(UpdateView):
42 fields = ['title', 'slug', 'text', 'tags']
45 class NoteAddView(CreateView):
47 fields = ['title', 'slug', 'text', 'tags']
50 class NoteDeleteView(DeleteView):
53 def get_success_url(self):
57 class HomeView(TemplateView):
58 template_name = 'phyll/home.html'