Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Sep 30, 2022
2 parents 33e5bb7 + 7be705f commit 89a5f92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cookbook/integration/recipekeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_recipe_from_file(self, file):
except AttributeError:
pass

step = Step.objects.create(instruction='', space=self.request.space,)
step = Step.objects.create(instruction='', space=self.request.space, )

ingredient_parser = IngredientParser(self.request, True)
for ingredient in file.find("div", {"itemprop": "recipeIngredients"}).findChildren("p"):
Expand All @@ -51,7 +51,7 @@ def get_recipe_from_file(self, file):
f = ingredient_parser.get_food(food)
u = ingredient_parser.get_unit(unit)
step.ingredients.add(Ingredient.objects.create(
food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space,
food=f, unit=u, amount=amount, note=note, original_text=str(ingredient).replace('<p>', '').replace('</p>', ''), space=self.request.space,
))

for s in file.find("div", {"itemprop": "recipeDirections"}).find_all("p"):
Expand Down
7 changes: 4 additions & 3 deletions cookbook/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,17 @@ def post(self, request, *args, **kwargs):
context={'request': request})
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
if token := AccessToken.objects.filter(scope__contains='read').filter(scope__contains='write').first():
if token := AccessToken.objects.filter(user=user, expires__gt=timezone.now(), scope__contains='read').filter(scope__contains='write').first():
access_token = token
else:
access_token = AccessToken.objects.create(user=request.user, token=f'tda_{str(uuid.uuid4()).replace("-", "_")}', expires=(timezone.now() + timezone.timedelta(days=365 * 5)), scope='read write app')
access_token = AccessToken.objects.create(user=user, token=f'tda_{str(uuid.uuid4()).replace("-", "_")}', expires=(timezone.now() + timezone.timedelta(days=365 * 5)), scope='read write app')
return Response({
'id': access_token.id,
'token': access_token.token,
'scope': access_token.scope,
'expires': access_token.expires,
'user_id': user.pk,
'user_id': access_token.user.pk,
'test': user.pk
})


Expand Down

0 comments on commit 89a5f92

Please sign in to comment.