Merge branch 'develop' into feature/meal-planning

# Conflicts:
#	requirements.txt
This commit is contained in:
vabene1111
2020-06-04 13:12:52 +02:00
21 changed files with 1429 additions and 38 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -118,7 +118,7 @@
<ul class="navbar-nav ml-auto">
{% if user.is_authenticated %}
<li class="nav-item dropdown {% if request.resolver_match.url_name in 'view_settings,view_history' %}active{% endif %}">
<li class="nav-item dropdown {% if request.resolver_match.url_name in 'view_settings,view_history,view_system,docs_markdown' %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"><i
class="fas fa-user-alt"></i> {{ user.get_user_name }}
@@ -130,6 +130,9 @@
<a class="dropdown-item" href="{% url 'view_history' %}"><i
class="fas fa-history"></i> {% trans 'History' %}</a>
{% if user.is_superuser %}
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'view_system' %}"><i
class="fas fa-server fa-fw"></i> {% trans 'System' %}</a>
<a class="dropdown-item" href="{% url 'admin:index' %}"><i
class="fas fa-user-shield fa-fw"></i> {% trans 'Admin' %}</a>
{% endif %}

View File

@@ -0,0 +1,66 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block title %}{% trans "Cookbook Setup" %}{% endblock %}
{% block extra_head %}
{{ form.media }}
{% endblock %}
{% block content %}
<h1>{% trans 'System Information' %}</h1>
{% blocktrans %}
Django Recipes is an open source free software application. It can be found on <a href="https://github.com/vabene1111/recipes">GitHub</a>.
Changelogs can be found <a href="https://github.com/vabene1111/recipes/releases">here</a>.
{% endblocktrans %}
<br/>
<br/>
<br/>
<h4>{% trans 'Media Serving' %} <span class="badge badge-{% if gunicorn_media %}danger{% else %}success{% endif %}">{% if gunicorn_media %}
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
{% if gunicorn_media %}
{% blocktrans %}Serving media files directly using gunicorn/python is <b>not recommend</b>!
Please follow the steps described
<a href="https://github.com/vabene1111/recipes/releases/tag/0.8.1">here</a> to update
your installation.
{% endblocktrans %}
{% else %}
{% trans 'Everything is fine!' %}
{% endif %}
<br/>
<br/>
<h4>{% trans 'Debug Mode' %} <span
class="badge badge-{% if debug %}danger{% else %}success{% endif %}">{% if debug %}
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
{% if debug %}
{% blocktrans %}
This application is still running in debug mode. This is most likely not needed. Turn of debug mode by
setting
<code>DEBUG=0</code> int the <code>.env</code> configuration file.
{% endblocktrans %}
{% else %}
{% trans 'Everything is fine!' %}
{% endif %}
<br/>
<br/>
<h4>{% trans 'Database' %} <span
class="badge badge-{% if postgres %}warning{% else %}success{% endif %}">{% if postgres %}
{% trans 'Info' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
{% if postgres %}
{% blocktrans %}
This application is not running with a Postgres database backend. This is ok but not recommended as some
features only work with postgres databases.
{% endblocktrans %}
{% else %}
{% trans 'Everything is fine!' %}
{% endif %}
<br/>
<br/>
{% endblock %}

View File

@@ -14,6 +14,7 @@ router.register(r'meal-type', api.MealTypeViewSet)
urlpatterns = [
path('', views.index, name='index'),
path('setup/', views.setup, name='view_setup'),
path('system/', views.system, name='view_system'),
path('search/', views.search, name='view_search'),
path('books/', views.books, name='view_books'),
path('plan/', views.meal_plan, name='view_plan'),

View File

@@ -1,4 +1,5 @@
import os
import uuid
from io import BytesIO
import simplejson
@@ -71,7 +72,7 @@ def internal_recipe_update(request, pk):
im_io = BytesIO()
img.save(im_io, 'PNG', quality=70)
recipe.image = File(im_io, name=(str(recipe.pk) + '.png'))
recipe.image = File(im_io, name=f'{uuid.uuid4()}_{recipe.pk}.png')
elif 'image' in form.changed_data and form.cleaned_data['image'] is False:
recipe.image = None

View File

@@ -23,6 +23,8 @@ from cookbook.tables import RecipeTable, RecipeTableSmall, CookLogTable, ViewLog
def index(request):
if not request.user.is_authenticated:
if User.objects.count() < 1 and 'django.contrib.auth.backends.RemoteUserBackend' not in settings.AUTHENTICATION_BACKENDS:
return HttpResponseRedirect(reverse_lazy('view_setup'))
return HttpResponseRedirect(reverse_lazy('view_search'))
try:
page_map = {
@@ -262,6 +264,12 @@ def history(request):
return render(request, 'history.html', {'view_log': view_log, 'cook_log': cook_log})
@group_required('admin')
def system(request):
postgres = False if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql_psycopg2' else True
return render(request, 'system.html', {'gunicorn_media': settings.GUNICORN_MEDIA, 'debug': settings.DEBUG, 'postgres': postgres})
def setup(request):
if User.objects.count() > 0 or 'django.contrib.auth.backends.RemoteUserBackend' in settings.AUTHENTICATION_BACKENDS:
messages.add_message(request, messages.ERROR, _('The setup page can only be used to create the first user! If you have forgotten your superuser credentials please consult the django documentation on how to reset passwords.'))