From cb35666f0e7174716ccb2860dd5bdba886aa0d89 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 18 Nov 2019 13:26:56 +0100 Subject: [PATCH] various fixes --- .idea/encodings.xml | 6 --- .idea/inspectionProfiles/Project_Default.xml | 15 -------- .idea/jsLibraryMappings.xml | 6 --- README.md | 24 +++++++----- .../migrations/0012_auto_20191118_1251.py | 18 +++++++++ cookbook/models.py | 2 +- cookbook/templates/recipe_view.html | 3 +- cookbook/views/edit.py | 37 ++++++++++++++++++- 8 files changed, 71 insertions(+), 40 deletions(-) delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/jsLibraryMappings.xml create mode 100644 cookbook/migrations/0012_auto_20191118_1251.py diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba45..000000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index cfb228678..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml deleted file mode 100644 index 6150fb772..000000000 --- a/.idea/jsLibraryMappings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 1ff1df91a..09d018dc0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -# Recipies -Recipes is a Django application that allows tagging of arbitrary numbers of recipes (or in fact any other file) in a storage backend. -It also allows the easy creation of recipes directly on the page. -Currently the only supported storage backend is dropbox, but this can easily be changed as the system is modular and -already has fields to support different backends. +# Recipes +Recipes is a django application to manage, tag and search recipes using either built in models or external storage providers hosting PDF's, Images or other files. + + + +Features + +- Sync files with Dropbox and Nextcloud (more can easily be added) +- Create and search for tags, assign them in batch to all files matching certain filters +- Create recipes locally within a nice, standardized webinterface +- Share recipes with friends and comment on them to suggest or remember changes you made + +This application is meant for people with a collection of recipes they want to share with family and friends or simply store them in a nicely organized way. A basic permission System will be implemented but this is not meant as a public website. ## Usage Most things should be straight forward but there are some more complicated things. @@ -21,8 +29,7 @@ Then enter the path you want to monitor starting at the storage root (e.g. `/Fol ##### Syncing Data To sync the recipes app with the storage backends press `Sync now` under `Manage Data >> Configure Sync`. ##### Import Recipes -All files found by the sync can be found under `Manage Data >> Import recipes`. There you can either import all at once without -modifying them or import one by one, adding Category and Tags while importing. +All files found by the sync can be found under `Manage Data >> Import recipes`. There you can either import all at once without modifying them or import one by one, adding Category and Tags while importing. ##### Batch Edit If you have many untagged recipes you may want to edit them all at once. For this go to `Manage Data >> Batch Edit`. Enter a word which should be contained in the recipe name and select the tags you want to apply. @@ -57,5 +64,4 @@ To start developing: Pull Requests and ideas are welcome, feel free to contribute in any way. ## License -This project is licensed under the MIT license. Even though it is not required to publish derivatives i highly encourage -pushing changes upstream and letting people profit from any work done on this project. \ No newline at end of file +This project is licensed under the MIT license. Even though it is not required to publish derivatives i highly encourage pushing changes upstream and letting people profit from any work done on this project. \ No newline at end of file diff --git a/cookbook/migrations/0012_auto_20191118_1251.py b/cookbook/migrations/0012_auto_20191118_1251.py new file mode 100644 index 000000000..04874a637 --- /dev/null +++ b/cookbook/migrations/0012_auto_20191118_1251.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.7 on 2019-11-18 11:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0011_recipe_time'), + ] + + operations = [ + migrations.AlterField( + model_name='recipe', + name='time', + field=models.IntegerField(default=0), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index c3347fbd3..e2b04c583 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -61,7 +61,7 @@ class Recipe(models.Model): file_path = models.CharField(max_length=512, default="") link = models.CharField(max_length=512, default="") keywords = models.ManyToManyField(Keyword, blank=True) - time = models.IntegerField(blank=True) + time = models.IntegerField(default=0) internal = models.BooleanField(default=False) created_by = models.ForeignKey(User, on_delete=models.PROTECT) created_at = models.DateTimeField(auto_now_add=True) diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 452599e0b..5a49b8ce4 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -86,8 +86,7 @@
{% csrf_token %}
- +
diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index d5a000f02..c3a56d2ad 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -52,7 +52,8 @@ def internal_recipe_update(request, pk): else: form = InternalRecipeForm(instance=recipe_instance) - return render(request, 'forms/edit_internal_recipe.html', {'form': form, 'view_url': reverse('view_recipe', args=[pk])}) + return render(request, 'forms/edit_internal_recipe.html', + {'form': form, 'view_url': reverse('view_recipe', args=[pk])}) class SyncUpdate(LoginRequiredMixin, UpdateView): @@ -103,6 +104,40 @@ class StorageUpdate(LoginRequiredMixin, UpdateView): return context +@login_required +def edit_storage(request, pk): + instance = get_object_or_404(Storage, pk=pk) + + if request.method == "POST": + form = StorageForm(request.POST) + if form.is_valid(): + instance.name = form.cleaned_data['name'] + instance.method = form.cleaned_data['method'] + instance.username = form.cleaned_data['username'] + instance.url = form.cleaned_data['url'] + + if form.cleaned_data['password'] != '__NO__CHANGE__': + instance.password = form.cleaned_data['password'] + + if form.cleaned_data['token'] != '__NO__CHANGE__': + instance.token = form.cleaned_data['token'] + + instance.save() + + messages.add_message(request, messages.SUCCESS, _('Storage saved!')) + return HttpResponseRedirect(reverse('edit_storage', args=[pk])) + else: + messages.add_message(request, messages.ERROR, _('There was an error updating this storage backend.!')) + else: + pseudo_instance = instance + pseudo_instance.password = '__NO__CHANGE__' + pseudo_instance.token = '__NO__CHANGE__' + form = InternalRecipeForm(instance=pseudo_instance) + + return render(request, 'forms/edit_internal_recipe.html', + {'form': form, 'view_url': reverse('view_recipe', args=[pk])}) + + class CommentUpdate(LoginRequiredMixin, UpdateView): template_name = "generic/edit_template.html" model = Comment