mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
added paprika import
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import re
|
||||
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from cookbook.forms import ExportForm, ExportForm, ImportForm
|
||||
from cookbook.forms import ExportForm, ImportForm, ImportExportBase
|
||||
from cookbook.helper.permission_helper import group_required
|
||||
from cookbook.integration.default import Default
|
||||
from cookbook.integration.paprika import Paprika
|
||||
from cookbook.models import Recipe
|
||||
|
||||
|
||||
def get_integration(request, export_type):
|
||||
return Default(request)
|
||||
if export_type == ImportExportBase.DEFAULT:
|
||||
return Default(request)
|
||||
if export_type == ImportExportBase.PAPRIKA:
|
||||
return Paprika(request)
|
||||
|
||||
|
||||
@group_required('user')
|
||||
@@ -17,8 +23,11 @@ def import_recipe(request):
|
||||
if request.method == "POST":
|
||||
form = ImportForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
integration = Default(request)
|
||||
return integration.do_import(request.FILES.getlist('files'))
|
||||
try:
|
||||
integration = get_integration(request, form.cleaned_data['type'])
|
||||
return integration.do_import(request.FILES.getlist('files'))
|
||||
except NotImplementedError:
|
||||
messages.add_message(request, messages.ERROR, _('Importing is not implemented for this provider'))
|
||||
else:
|
||||
form = ImportForm()
|
||||
|
||||
@@ -30,8 +39,12 @@ def export_recipe(request):
|
||||
if request.method == "POST":
|
||||
form = ExportForm(request.POST)
|
||||
if form.is_valid():
|
||||
integration = Default(request)
|
||||
return integration.do_export(form.cleaned_data['recipes'])
|
||||
try:
|
||||
integration = get_integration(request, form.cleaned_data['type'])
|
||||
return integration.do_export(form.cleaned_data['recipes'])
|
||||
except NotImplementedError:
|
||||
messages.add_message(request, messages.ERROR, _('Exporting is not implemented for this provider'))
|
||||
|
||||
else:
|
||||
form = ExportForm()
|
||||
recipe = request.GET.get('r')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from django.conf import settings
|
||||
@@ -11,7 +11,7 @@ from django.contrib.auth.password_validation import validate_password
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import IntegrityError
|
||||
from django.db.models import Avg, Q
|
||||
from django.http import HttpResponseRedirect, FileResponse, HttpResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render, redirect
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
@@ -22,9 +22,8 @@ from rest_framework.authtoken.models import Token
|
||||
from cookbook.filters import RecipeFilter
|
||||
from cookbook.forms import (CommentForm, Recipe, RecipeBookEntryForm, User,
|
||||
UserCreateForm, UserNameForm, UserPreference,
|
||||
UserPreferenceForm, ImportForm, ImportForm, ExportForm)
|
||||
UserPreferenceForm)
|
||||
from cookbook.helper.permission_helper import group_required, share_link_valid, has_group_permission
|
||||
from cookbook.integration.default import Default
|
||||
from cookbook.models import (Comment, CookLog, InviteLink, MealPlan,
|
||||
RecipeBook, RecipeBookEntry, ViewLog, ShoppingList)
|
||||
from cookbook.tables import (CookLogTable, RecipeTable, RecipeTableSmall,
|
||||
|
||||
Reference in New Issue
Block a user