Skip to content

Commit

Permalink
Merge pull request #1158 from zestedesavoir/hotfix-tutorials-problem
Browse files Browse the repository at this point in the history
Hotfix problemes dans les tutos
  • Loading branch information
dralliw committed Jul 13, 2014
2 parents 69e1f00 + d2ee322 commit 746d9d0
Show file tree
Hide file tree
Showing 9 changed files with 530 additions and 101 deletions.
19 changes: 13 additions & 6 deletions templates/tutorial/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,35 @@ <h3>Télécharger</h3>
<ul>
{% if tutorial.on_line %}
{% if perms.tutorial.change_tutorial %}
<li>
<a href="{% url "zds.tutorial.views.download_markdown" %}?tutoriel={{ tutorial.pk }}" class="ico-after download blue">
Markdown
</a>
</li>
{% if tutorial.have_markdown %}
<li>
<a href="{% url "zds.tutorial.views.download_markdown" %}?tutoriel={{ tutorial.pk }}" class="ico-after download blue">
Markdown
</a>
</li>
{% endif %}
{% endif %}

{% if tutorial.have_html %}
<li>
<a href="{% url "zds.tutorial.views.download_html" %}?tutoriel={{ tutorial.pk }}" class="ico-after download blue">
HTML
</a>
</li>
{% endif %}
{% if tutorial.have_pdf %}
<li>
<a href="{% url "zds.tutorial.views.download_pdf" %}?tutoriel={{ tutorial.pk }}" class="ico-after download blue">
PDF
</a>
</li>
{% endif %}
{% if tutorial.have_epub %}
<li>
<a href="{% url "zds.tutorial.views.download_epub" %}?tutoriel={{ tutorial.pk }}" class="ico-after download blue">
EPUB
</a>
</li>
{% endif %}
{% endif %}

<li>
Expand Down
2 changes: 1 addition & 1 deletion templates/tutorial/chapter/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% with authors=tutorial.authors.all %}
<h1 {% if chapter.image %}class="illu"{% endif %}>
{% if chapter.image %}
<img src="{{ chapter.image.thumb.url }}" alt="">
<img src="{{ chapter.image.physical.tutorial_illu.url }}" alt="">
{% endif %}
{{ chapter.title }}
</h1>
Expand Down
6 changes: 3 additions & 3 deletions templates/tutorial/includes/chapter.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2 id="{{ extract.position_in_chapter }}-{{ extract.title|slugify }}">
</a>
</h2>

{% if user in authors %}
{% if user in authors or perms.tutorial.change_tutorial %}
<div class="actions-title">
<a href="#delete-{{ extract.pk }}" class="open-modal ico-after cross btn btn-grey">Supprimer</a>
<form action="{% url "zds.tutorial.views.modify_extract" %}" method="post" id="delete-{{ extract.pk }}" class="modal modal-small">
Expand All @@ -56,7 +56,7 @@ <h2 id="{{ extract.position_in_chapter }}-{{ extract.title|slugify }}">
<a href="#move-extract-{{ extract.pk }}" class="open-modal ico-after move btn btn-grey">Déplacer</a>
<form action="{% url "zds.tutorial.views.modify_extract" %}" method="post" class="modal modal-small" id="move-extract-{{ extract.pk }}">
<select name="move_target">
<option>Déplacer</option>
<option disabled="disabled">Déplacer</option>
{% if extract.position_in_chapter > 1 %}
<option value="{{ extract.position_in_chapter|add:-1 }}">Monter</option>
{% endif %}
Expand Down Expand Up @@ -88,7 +88,7 @@ <h2 id="{{ extract.position_in_chapter }}-{{ extract.title|slugify }}">

{% csrf_token %}
<button type="submit">
Confirmer
Déplacer
</button>
</form>

Expand Down
18 changes: 18 additions & 0 deletions templates/tutorial/part/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ <h4>
<a href="#move-part" class="open-modal ico-after move blue">
Déplacer <span class="wide">la partie</span>
</a>

<form action="{% url "zds.tutorial.views.modify_part" %}" method="POST" class="modal modal-small" id="move-part">
<select name="move_target" class="select-autosubmit">
<option disabled="disabled">
Expand Down Expand Up @@ -174,6 +175,23 @@ <h4>
<button type="submit">Déplacer</button>
</form>
</li>
<li>
<a href="#delete-part" class="open-modal ico-after cross red">
Supprimer la partie
</a>

<form action="{% url "zds.tutorial.views.modify_part" %}" method="post" id="delete-part" class="modal modal-medium">
<p>
Attention, vous vous apprêtez à supprimer définitivement la partie "<em>{{ part.title }}</em>".
</p>
<input type="hidden" name="part" value="{{ part.pk }}">

{% csrf_token %}
<button type="submit" name="delete">
Confirmer
</button>
</form>
</li>
{% endif %}
{% endif %}
{% endblock %}
Expand Down
9 changes: 9 additions & 0 deletions templates/tutorial/tutorial/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ <h2>
{% crispy formAskValidation %}
</div>
</li>
{% elif tutorial.sha_validation != version %}
<li>
<a href="#ask-validation" class="open-modal ico-after tick green">
Mettre à jour la version en validation
</a>
<div id="ask-validation" class="modal modal-medium">
{% crispy formAskValidation %}
</div>
</li>
{% else %}
<li class="inactive">
<span class="ico-after tick disabled">En attente de validation</span>
Expand Down
2 changes: 1 addition & 1 deletion zds/article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def history(request, article_pk, article_slug):
"""Display an article."""
article = get_object_or_404(Article, pk=article_pk)

if not article.on_line \
if not article.on_line() \
and not request.user.has_perm('article.change_article') \
and request.user not in article.authors.all():
raise Http404
Expand Down
30 changes: 27 additions & 3 deletions zds/tutorial/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def in_drafting(self):
return (self.sha_draft is not None) and (self.sha_draft.strip() != '')

def on_line(self):
return (self.sha_public is not None) and (self.sha_public.strip() != '')
return (self.sha_public is not None) and (self.sha_public.strip() != '')

def is_mini(self):
return self.type == 'MINI'
Expand Down Expand Up @@ -196,6 +196,10 @@ def load_dic(self, mandata):
mandata['image'] = self.image
mandata['pubdate'] = self.pubdate
mandata['source'] = self.source
mandata['have_markdown'] = self.have_markdown()
mandata['have_html'] = self.have_html()
mandata['have_pdf'] = self.have_pdf()
mandata['have_epub'] = self.have_epub()

return mandata

Expand Down Expand Up @@ -358,6 +362,22 @@ def update_children(self):
if chapter:
chapter.update_children()

def have_markdown(self):
return os.path.isfile(os.path.join(self.get_prod_path(),
self.slug +
".md"))
def have_html(self):
return os.path.isfile(os.path.join(self.get_prod_path(),
self.slug +
".html"))
def have_pdf(self):
return os.path.isfile(os.path.join(self.get_prod_path(),
self.slug +
".pdf"))
def have_epub(self):
return os.path.isfile(os.path.join(self.get_prod_path(),
self.slug +
".epub"))

def get_last_tutorials():
tutorials = Tutorial.objects.all()\
Expand Down Expand Up @@ -775,8 +795,12 @@ def get_conclusion_online(self):
return None

def update_children(self):
self.introduction = os.path.join(self.get_phy_slug(), "introduction.md")
self.conclusion = os.path.join(self.get_phy_slug(), "conclusion.md")
if self.part:
self.introduction = os.path.join(self.part.get_phy_slug(), self.get_phy_slug(), "introduction.md")
self.conclusion = os.path.join(self.part.get_phy_slug(), self.get_phy_slug(), "conclusion.md")
else:
self.introduction = os.path.join("introduction.md")
self.conclusion = os.path.join("conclusion.md")
self.save()
for extract in self.get_extracts():
extract.save()
Expand Down
Loading

0 comments on commit 746d9d0

Please sign in to comment.