add basic views to create/edit/delete notes
[chloro.git] / chloro / phyll / views.py
index cb12807..d13d6b9 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from django.views.generic import DetailView
+from django.views.generic import CreateView, DeleteView, DetailView, UpdateView
 
 from .models import Note
 
 
 class NoteView(DetailView):
     model = Note
+
+
+class NoteEditView(UpdateView):
+    model = Note
+    fields = ['title', 'slug', 'text', 'tags']
+
+
+class NoteAddView(CreateView):
+    model = Note
+    fields = ['title', 'slug', 'text', 'tags']
+
+
+class NoteDeleteView(DeleteView):
+    model = Note
+
+    def get_success_url(self):
+        return '/'