Commit e6483324 authored by Bonnegent Sebastien's avatar Bonnegent Sebastien
Browse files

cours 5 ok

parent 51fd4f29
......@@ -121,6 +121,7 @@ $ pipenv install</code></pre>
<li>modifier</li>
<li>les menus</li>
<li>supprimer</li>
<li>debugger</li>
</ul>
</section></section>
<section><section id="créer" class="title-slide slide level1"><h1>Créer</h1></section><section id="parefeu" class="slide level2">
......@@ -222,7 +223,7 @@ $ pipenv install</code></pre>
<h2>Parefeu</h2>
<h3 id="à-faire-1">À faire</h3>
<ul>
<li>ajouter un bouton de suppression sur la page de détail d’un parefeu</li>
<li>ajouter un bouton de modification sur la page de détail d’un parefeu</li>
</ul>
</section></section>
<section><section id="menu" class="title-slide slide level1"><h1>Menu</h1></section><section id="factorisation" class="slide level2">
......@@ -248,7 +249,53 @@ $ pipenv install</code></pre>
<a class="sourceLine" id="cb12-10" title="10"><span class="kw">class</span> ParefeuList(ParefeuMenu, ListView):</a>
<a class="sourceLine" id="cb12-11" title="11"><span class="co"># supprimer get_context_data()</span></a></code></pre></div>
</section></section>
<section><section id="supprimer" class="title-slide slide level1"><h1>Supprimer</h1></section></section>
<section><section id="supprimer" class="title-slide slide level1"><h1>Supprimer</h1></section><section id="parefeu-10" class="slide level2">
<h2>Parefeu</h2>
<h3 id="webuiviews.py-4">webui/views.py</h3>
<div class="sourceCode" id="cb13"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb13-1" title="1"><span class="im">from</span> django.views.generic.edit <span class="im">import</span> DeleteView</a>
<a class="sourceLine" id="cb13-2" title="2"><span class="im">from</span> django.urls <span class="im">import</span> reverse_lazy</a>
<a class="sourceLine" id="cb13-3" title="3"></a>
<a class="sourceLine" id="cb13-4" title="4"><span class="kw">class</span> ParefeuDelete(ParefeuMenu, DeleteView):</a>
<a class="sourceLine" id="cb13-5" title="5"> model <span class="op">=</span> Parefeu</a>
<a class="sourceLine" id="cb13-6" title="6"> <span class="co"># lazy: interprétation plus tard</span></a>
<a class="sourceLine" id="cb13-7" title="7"> success_url <span class="op">=</span> reverse_lazy(<span class="st">&#39;parefeux&#39;</span>)</a></code></pre></div>
</section><section id="parefeu-11" class="slide level2">
<h2>Parefeu</h2>
<h3 id="webuitemplateswebuiparefeu_confirm_delete.html">webui/templates/webui/parefeu_confirm_delete.html</h3>
<pre><code>{% extends &quot;webui/home.html&quot; %}
{% block content %}
&lt;h1&gt;Suppression&lt;/h1&gt;&lt;form method=&quot;post&quot;&gt;{% csrf_token %}
&lt;p&gt;Êtes-vous sûr de vouloir supprimer le parefeu &#39;{{ object.nom }}&#39; ?&lt;/p&gt;
&lt;a href=&quot;{% url &#39;parefeu-detail&#39; object.pk %}&quot;
class=&quot;btn btn-primary&quot; role=&quot;button&quot;&gt;Annuler&lt;/a&gt;
&lt;button class=&quot;btn btn-danger&quot; type=&quot;submit&quot;/&gt;Supprimer&lt;/button&gt;
&lt;/form&gt;
{% endblock %}</code></pre>
</section><section id="parefeu-12" class="slide level2">
<h2>Parefeu</h2>
<h3 id="confurls.py-2">conf/urls.py</h3>
<div class="sourceCode" id="cb15"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb15-1" title="1">path(<span class="st">&#39;parefeu/&lt;int:pk&gt;/delete/&#39;</span>,</a>
<a class="sourceLine" id="cb15-2" title="2"> login_required(views.ParefeuDelete.as_view()),</a>
<a class="sourceLine" id="cb15-3" title="3"> name<span class="op">=</span><span class="st">&#39;parefeu-delete&#39;</span>),</a></code></pre></div>
</section><section id="parefeu-13" class="slide level2">
<h2>Parefeu</h2>
<h3 id="à-faire-2">À faire</h3>
<ul>
<li>ajouter un bouton de suppression sur la page de détail d’un parefeu</li>
<li>créer un nouveau parefeu</li>
<li>le supprimer</li>
</ul>
</section></section>
<section><section id="debugger" class="title-slide slide level1"><h1>Debugger</h1></section><section id="prérequis" class="slide level2">
<h2>Prérequis</h2>
<pre><code>$ pipenv install --dev Werkzeug
$ pipenv run ./manage.py runserver_plus --nopin</code></pre>
</section><section id="utiliser" class="slide level2">
<h2>Utiliser</h2>
<div class="sourceCode" id="cb17"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb17-1" title="1"><span class="kw">def</span> home_v2(request):</a>
<a class="sourceLine" id="cb17-2" title="2"> a <span class="op">+=</span> <span class="dv">1</span></a>
<a class="sourceLine" id="cb17-3" title="3">...</a></code></pre></div>
</section></section>
<section><section id="fin" class="title-slide slide level1"><h1>FIN !</h1></section></section>
</div>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment