various fixes

This commit is contained in:
vabene1111
2019-11-18 13:26:56 +01:00
parent 404516d677
commit cb35666f0e
8 changed files with 71 additions and 40 deletions

6
.idea/encodings.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -1,15 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="dotenv" />
<item index="1" class="java.lang.String" itemvalue="psycopg2" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{bootstrap, jquery-3.2.1.slim, jquery-3.3.1, popper, select2, tabulator}" />
</component>
</project>

View File

@ -1,8 +1,16 @@
# Recipies # Recipes
Recipes is a Django application that allows tagging of arbitrary numbers of recipes (or in fact any other file) in a storage backend. 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.
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.
<u>Features</u>
- 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 ## Usage
Most things should be straight forward but there are some more complicated things. 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 ##### Syncing Data
To sync the recipes app with the storage backends press `Sync now` under `Manage Data >> Configure Sync`. To sync the recipes app with the storage backends press `Sync now` under `Manage Data >> Configure Sync`.
##### Import Recipes ##### 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 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.
modifying them or import one by one, adding Category and Tags while importing.
##### Batch Edit ##### Batch Edit
If you have many untagged recipes you may want to edit them all at once. For this go to 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. `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. Pull Requests and ideas are welcome, feel free to contribute in any way.
## License ## License
This project is licensed under the MIT license. Even though it is not required to publish derivatives i highly encourage 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.
pushing changes upstream and letting people profit from any work done on this project.

View File

@ -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),
),
]

View File

@ -61,7 +61,7 @@ class Recipe(models.Model):
file_path = models.CharField(max_length=512, default="") file_path = models.CharField(max_length=512, default="")
link = models.CharField(max_length=512, default="") link = models.CharField(max_length=512, default="")
keywords = models.ManyToManyField(Keyword, blank=True) keywords = models.ManyToManyField(Keyword, blank=True)
time = models.IntegerField(blank=True) time = models.IntegerField(default=0)
internal = models.BooleanField(default=False) internal = models.BooleanField(default=False)
created_by = models.ForeignKey(User, on_delete=models.PROTECT) created_by = models.ForeignKey(User, on_delete=models.PROTECT)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)

View File

@ -86,8 +86,7 @@
<form method="POST" class="post-form"> <form method="POST" class="post-form">
{% csrf_token %} {% csrf_token %}
<div class="input-group mb-3"> <div class="input-group mb-3">
<textarea name="text" cols="15" rows="2" class="textarea form-control" required id="id_text"> <textarea name="text" cols="15" rows="2" class="textarea form-control" required id="id_text"></textarea>
</textarea>
<div class="input-group-append"> <div class="input-group-append">
<input type="submit" value="{% trans 'Comment' %}" class="btn btn-success"> <input type="submit" value="{% trans 'Comment' %}" class="btn btn-success">
</div> </div>

View File

@ -52,7 +52,8 @@ def internal_recipe_update(request, pk):
else: else:
form = InternalRecipeForm(instance=recipe_instance) 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): class SyncUpdate(LoginRequiredMixin, UpdateView):
@ -103,6 +104,40 @@ class StorageUpdate(LoginRequiredMixin, UpdateView):
return context 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): class CommentUpdate(LoginRequiredMixin, UpdateView):
template_name = "generic/edit_template.html" template_name = "generic/edit_template.html"
model = Comment model = Comment