mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
view local recipes
This commit is contained in:
@@ -67,7 +67,7 @@ class Recipe(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def all_tags(self):
|
def all_tags(self):
|
||||||
return ', '.join([(x.icon + x.name) for x in self.keywords.all()])
|
return ' '.join([(x.icon + x.name) for x in self.keywords.all()])
|
||||||
|
|
||||||
|
|
||||||
class RecipeIngredients(models.Model):
|
class RecipeIngredients(models.Model):
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
xhttp.onreadystatechange = function () {
|
xhttp.onreadystatechange = function () {
|
||||||
if (this.readyState === 4 && this.status === 200) {
|
if (this.readyState === 4 && this.status === 200) {
|
||||||
|
window.open(this.responseText);
|
||||||
link.attr("href", this.responseText);
|
link.attr("href", this.responseText);
|
||||||
link.show();
|
link.show();
|
||||||
$('#div_loader').hide();
|
$('#div_loader').hide();
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>{{ recipe.name }}</h3>
|
<h3>{{ recipe.name }} <a href="{% url 'edit_recipe' recipe.pk %}"><i class="fas fa-pencil-alt"></i></a></h3>
|
||||||
|
{% if recipe.all_tags %}
|
||||||
|
{{ recipe.all_tags }}
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
<br/>
|
<br/>
|
||||||
<div class="card" style="width: 18rem;">
|
<div class="card" style="width: 18rem;">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
|
from django.urls import reverse_lazy, reverse
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
@@ -12,6 +13,8 @@ from cookbook.helper import dropbox
|
|||||||
def get_file_link(request, recipe_id):
|
def get_file_link(request, recipe_id):
|
||||||
recipe = Recipe.objects.get(id=recipe_id)
|
recipe = Recipe.objects.get(id=recipe_id)
|
||||||
|
|
||||||
|
if recipe.instructions:
|
||||||
|
return HttpResponse(reverse('view_recipe', args=[recipe_id]))
|
||||||
if recipe.storage.method == Storage.DROPBOX:
|
if recipe.storage.method == Storage.DROPBOX:
|
||||||
if recipe.link == "":
|
if recipe.link == "":
|
||||||
recipe.link = dropbox.get_share_link(recipe) # TODO response validation
|
recipe.link = dropbox.get_share_link(recipe) # TODO response validation
|
||||||
|
|||||||
Reference in New Issue
Block a user