mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-28 20:49:22 -05:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7c4e11c9 | ||
|
|
745bb58c7e | ||
|
|
13115a1e53 |
@@ -1,3 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
@@ -349,8 +351,8 @@ class InviteLinkForm(forms.ModelForm):
|
||||
|
||||
def clean(self):
|
||||
space = self.cleaned_data['space']
|
||||
if space.max_users != 0 and (UserPreference.objects.filter(space=space).count() + InviteLink.objects.filter(
|
||||
space=space).count()) >= space.max_users:
|
||||
if space.max_users != 0 and (UserPreference.objects.filter(space=space).count() +
|
||||
InviteLink.objects.filter(valid_until__gte=datetime.today(), used_by=None, space=space).count()) >= space.max_users:
|
||||
raise ValidationError(_('Maximum number of users for this space reached.'))
|
||||
|
||||
def clean_email(self):
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import random
|
||||
import re
|
||||
from html import unescape
|
||||
|
||||
from django.utils.dateparse import parse_duration
|
||||
from isodate import parse_duration as iso_parse_duration
|
||||
from isodate.isoerror import ISO8601Error
|
||||
from recipe_scrapers._utils import get_minutes
|
||||
|
||||
from cookbook.helper import recipe_url_import as helper
|
||||
from cookbook.helper.ingredient_parser import IngredientParser
|
||||
from cookbook.models import Keyword
|
||||
from django.utils.dateparse import parse_duration
|
||||
from html import unescape
|
||||
from recipe_scrapers._utils import get_minutes
|
||||
|
||||
|
||||
def get_from_scraper(scrape, request):
|
||||
@@ -96,8 +98,9 @@ def get_from_scraper(scrape, request):
|
||||
recipe_json['keywords'] = keywords
|
||||
|
||||
ingredient_parser = IngredientParser(request, True)
|
||||
|
||||
ingredients = []
|
||||
try:
|
||||
ingredients = []
|
||||
for x in scrape.ingredients():
|
||||
try:
|
||||
amount, unit, ingredient, note = ingredient_parser.parse(x)
|
||||
|
||||
@@ -916,7 +916,16 @@ def recipe_from_source(request):
|
||||
},
|
||||
status=400
|
||||
)
|
||||
if len(scrape.ingredients()) and len(scrape.instructions()) == 0:
|
||||
|
||||
try:
|
||||
instructions = scrape.instructions()
|
||||
except Exception:
|
||||
instructions = ""
|
||||
try:
|
||||
ingredients = scrape.ingredients()
|
||||
except Exception:
|
||||
ingredients = []
|
||||
if len(ingredients) + len(instructions) == 0:
|
||||
return JsonResponse(
|
||||
{
|
||||
'error': True,
|
||||
|
||||
@@ -30,7 +30,7 @@ Jinja2==3.0.3
|
||||
django-webpack-loader==1.4.1
|
||||
django-js-reverse==0.9.1
|
||||
django-allauth==0.46.0
|
||||
recipe-scrapers==13.7.0
|
||||
recipe-scrapers==13.10.1
|
||||
django-scopes==1.2.0
|
||||
pytest==6.2.5
|
||||
pytest-django==4.5.1
|
||||
@@ -41,4 +41,4 @@ boto3==1.20.19
|
||||
django-prometheus==2.1.0
|
||||
django-hCaptcha==0.1.0
|
||||
python-ldap==3.4.0
|
||||
django-auth-ldap==3.0.0
|
||||
django-auth-ldap==3.0.0
|
||||
|
||||
Reference in New Issue
Block a user