diff --git a/cookbook/helper/AllAuthCustomAdapter.py b/cookbook/helper/AllAuthCustomAdapter.py index d3c03e43..a1affa4c 100644 --- a/cookbook/helper/AllAuthCustomAdapter.py +++ b/cookbook/helper/AllAuthCustomAdapter.py @@ -1,11 +1,10 @@ import datetime - -from django.conf import settings +from gettext import gettext as _ from allauth.account.adapter import DefaultAccountAdapter +from django.conf import settings from django.contrib import messages from django.core.cache import caches -from gettext import gettext as _ from cookbook.models import InviteLink @@ -17,7 +16,8 @@ class AllAuthCustomAdapter(DefaultAccountAdapter): Whether to allow sign-ups. """ signup_token = False - if 'signup_token' in request.session and InviteLink.objects.filter(valid_until__gte=datetime.datetime.today(), used_by=None, uuid=request.session['signup_token']).exists(): + if 'signup_token' in request.session and InviteLink.objects.filter( + valid_until__gte=datetime.datetime.today(), used_by=None, uuid=request.session['signup_token']).exists(): signup_token = True if request.resolver_match.view_name == 'account_signup' and not settings.ENABLE_SIGNUP and not signup_token: @@ -35,7 +35,7 @@ class AllAuthCustomAdapter(DefaultAccountAdapter): if c == default: try: super(AllAuthCustomAdapter, self).send_mail(template_prefix, email, context) - except Exception: # dont fail signup just because confirmation mail could not be send + except Exception: # dont fail signup just because confirmation mail could not be send pass else: messages.add_message(self.request, messages.ERROR, _('In order to prevent spam, the requested email was not send. Please wait a few minutes and try again.')) diff --git a/cookbook/helper/__init__.py b/cookbook/helper/__init__.py index c1cb3788..e4fea45a 100644 --- a/cookbook/helper/__init__.py +++ b/cookbook/helper/__init__.py @@ -1,6 +1,3 @@ -import cookbook.helper.dal -from cookbook.helper.AllAuthCustomAdapter import AllAuthCustomAdapter - __all__ = [ 'dal', ] diff --git a/cookbook/helper/open_data_importer.py b/cookbook/helper/open_data_importer.py index 34aeae5d..bd88975a 100644 --- a/cookbook/helper/open_data_importer.py +++ b/cookbook/helper/open_data_importer.py @@ -1,6 +1,5 @@ -from django.db.models import Q - -from cookbook.models import Unit, SupermarketCategory, Property, PropertyType, Supermarket, SupermarketCategoryRelation, Food, Automation, UnitConversion, FoodProperty +from cookbook.models import (Food, FoodProperty, Property, PropertyType, Supermarket, + SupermarketCategory, SupermarketCategoryRelation, Unit, UnitConversion) class OpenDataImporter: @@ -33,7 +32,8 @@ class OpenDataImporter: )) if self.update_existing: - return Unit.objects.bulk_create(insert_list, update_conflicts=True, update_fields=('name', 'plural_name', 'base_unit', 'open_data_slug'), unique_fields=('space', 'name',)) + return Unit.objects.bulk_create(insert_list, update_conflicts=True, update_fields=( + 'name', 'plural_name', 'base_unit', 'open_data_slug'), unique_fields=('space', 'name',)) else: return Unit.objects.bulk_create(insert_list, update_conflicts=True, update_fields=('open_data_slug',), unique_fields=('space', 'name',)) @@ -166,7 +166,7 @@ class OpenDataImporter: self._update_slug_cache(Food, 'food') food_property_list = [] - alias_list = [] + # alias_list = [] for k in list(self.data[datatype].keys()): for fp in self.data[datatype][k]['properties']['type_values']: @@ -180,15 +180,6 @@ class OpenDataImporter: )) except KeyError: print(str(k) + ' is not in self.slug_id_cache["food"]') - - - # for a in self.data[datatype][k]['alias']: - # alias_list.append(Automation( - # param_1=a, - # param_2=self.data[datatype][k]['name'], - # space=self.request.space, - # created_by=self.request.user, - # )) Property.objects.bulk_create(food_property_list, ignore_conflicts=True, unique_fields=('space', 'import_food_id', 'property_type',)) diff --git a/cookbook/helper/property_helper.py b/cookbook/helper/property_helper.py index ed19990c..04521c65 100644 --- a/cookbook/helper/property_helper.py +++ b/cookbook/helper/property_helper.py @@ -2,7 +2,7 @@ from django.core.cache import caches from cookbook.helper.cache_helper import CacheHelper from cookbook.helper.unit_conversion_helper import UnitConversionHelper -from cookbook.models import PropertyType, Unit, Food, Property, Recipe, Step +from cookbook.models import PropertyType class FoodPropertyHelper: @@ -31,10 +31,12 @@ class FoodPropertyHelper: if not property_types: property_types = PropertyType.objects.filter(space=self.space).all() - caches['default'].set(CacheHelper(self.space).PROPERTY_TYPE_CACHE_KEY, property_types, 60 * 60) # cache is cleared on property type save signal so long duration is fine + # cache is cleared on property type save signal so long duration is fine + caches['default'].set(CacheHelper(self.space).PROPERTY_TYPE_CACHE_KEY, property_types, 60 * 60) for fpt in property_types: - computed_properties[fpt.id] = {'id': fpt.id, 'name': fpt.name, 'description': fpt.description, 'unit': fpt.unit, 'order': fpt.order, 'food_values': {}, 'total_value': 0, 'missing_value': False} + computed_properties[fpt.id] = {'id': fpt.id, 'name': fpt.name, 'description': fpt.description, + 'unit': fpt.unit, 'order': fpt.order, 'food_values': {}, 'total_value': 0, 'missing_value': False} uch = UnitConversionHelper(self.space) @@ -53,7 +55,8 @@ class FoodPropertyHelper: if c.unit == i.food.properties_food_unit: found_property = True computed_properties[pt.id]['total_value'] += (c.amount / i.food.properties_food_amount) * p.property_amount - computed_properties[pt.id]['food_values'] = self.add_or_create(computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food) + computed_properties[pt.id]['food_values'] = self.add_or_create( + computed_properties[p.property_type.id]['food_values'], c.food.id, (c.amount / i.food.properties_food_amount) * p.property_amount, c.food) if not found_property: computed_properties[pt.id]['missing_value'] = True computed_properties[pt.id]['food_values'][i.food.id] = {'id': i.food.id, 'food': i.food.name, 'value': 0} diff --git a/cookbook/helper/scope_middleware.py b/cookbook/helper/scope_middleware.py index a0218f08..9ab70574 100644 --- a/cookbook/helper/scope_middleware.py +++ b/cookbook/helper/scope_middleware.py @@ -1,8 +1,6 @@ from django.urls import reverse from django_scopes import scope, scopes_disabled from oauth2_provider.contrib.rest_framework import OAuth2Authentication -from rest_framework.authentication import TokenAuthentication -from rest_framework.authtoken.models import Token from rest_framework.exceptions import AuthenticationFailed from cookbook.views import views diff --git a/cookbook/urls.py b/cookbook/urls.py index 03767562..e8be5160 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -9,10 +9,10 @@ from cookbook.helper import dal from cookbook.version_info import TANDOOR_VERSION from recipes.settings import DEBUG, PLUGINS -from .models import (Automation, Comment, CustomFilter, Food, InviteLink, Keyword, MealPlan, - PropertyType, Recipe, RecipeBook, RecipeBookEntry, RecipeImport, ShoppingList, - Space, Step, Storage, Supermarket, SupermarketCategory, Sync, SyncLog, Unit, - UnitConversion, UserFile, UserSpace, get_model_name) +from .models import (Automation, Comment, CustomFilter, Food, InviteLink, Keyword, PropertyType, + Recipe, RecipeBook, RecipeBookEntry, RecipeImport, ShoppingList, Space, Step, + Storage, Supermarket, SupermarketCategory, Sync, SyncLog, Unit, UnitConversion, + UserFile, UserSpace, get_model_name) from .views import api, data, delete, edit, import_export, lists, new, telegram, views from .views.api import CustomAuthToken, ImportOpenData diff --git a/vue/tsconfig.json b/vue/tsconfig.json index 63fe664a..77083526 100644 --- a/vue/tsconfig.json +++ b/vue/tsconfig.json @@ -3,6 +3,7 @@ "target": "es5", "module": "esnext", "strict": true, + "allowJs": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", @@ -32,8 +33,9 @@ "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", - "tests/**/*.tsx" -, "src/directives/OutsideClick.js" ], + "tests/**/*.tsx", + "src/directives/OutsideClick.js" + ], "exclude": [ "node_modules" ]