Advertisement
akonrad

Module 10 Review Form script.html

Apr 4th, 2020
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 5.45 KB | None | 0 0
  1. {% extends "share/base.html" %}
  2.  
  3. {% block content %}
  4.  
  5. <!-- objects passed by the view function: user, script, problem, reviews, user_review -->
  6.  
  7. {% if error %}
  8.   <h3 class="title is-3" style="color: red">{{ error }}</h3>
  9. {% endif %}
  10.  
  11. <!--
  12. <hr> ##### testing ####  <br>
  13. problem: {{problem}} <br>
  14. script: {{script}} <br>
  15. reviews: {{reviews}} <br>
  16. user_review: {{ user_review }} <br>
  17. ######################## <br>
  18. -->
  19.  
  20. <div class="columns">
  21.  
  22. <div class="column is-three-forths-widescreen" >
  23.  
  24. <h2 class="title is-2">Python script: {{ script.title }} <br>Written by {{ script.coder.user.username}}</h2>
  25.         <div class="box">
  26.         <div class="content">
  27.  
  28.               <br>
  29.               Description: {{ script.description }} <br>
  30.  
  31.               {% if script.url %}
  32.               URL: {{ script.url }} <br>
  33.               {% endif %}
  34.  
  35.               {% if script.input %}
  36.               Input: {{ script.input }} <br>
  37.               {% endif %}
  38.  
  39.               {% if script.output %}
  40.               Output: {{ script.output }} <br>
  41.               {% endif %}
  42.  
  43.               {% if script.working_code %}
  44.                 This script is working! <br><br>
  45.               {% else %}
  46.                 This script is not yet working!<br><br>
  47.               {% endif %}
  48.  
  49.               Created on {{ script.created }}, Updated on {{ script.updated }} <br><br>
  50.  
  51.               {% if script.make_public %}
  52.                 This script is public! <br><br>
  53.               {% else %}
  54.                 This script is private!<br><br>
  55.               {% endif %}
  56.  
  57.               <!-- create a link to the problem that it solves -->
  58.               Problem that solves:
  59.               <a class="button is-primary is-small" href="{% url 'share:show_problem' problem.id %}">  {{ problem.title}} </a>,
  60.               posted by {{problem.coder.user.username}} <br>
  61.               <br>
  62.               <br>
  63.               <div class="box">     <!-- we should also show the RAW text --> <!-- See pastebin -->
  64.               Python code:
  65.                     <div class="code">
  66.                           <br>{{ script.code }}
  67.                       </div>
  68.               </div>
  69.  
  70.               <br>
  71.               {% if user.id == script.coder.user.id %}
  72.               <a class="button is-primary is-medium" href="{% url 'share:edit_script' script.id %}">Make changes to this script ... </a>
  73.  
  74.               {% endif %}
  75.  
  76.               <!-- Module 10 Review form -->
  77.               <!-- if the user has already written a review, show the content of the review on the right column, button to delete -->
  78.  
  79.               <!-- if the logged user has not written a review yet and
  80.              she is not the author of the script, then show the review form -->
  81.               {% if not user_review and user.id != script.coder.user.id %}
  82.                       <h2 class="title is-4">Write your review </h2>
  83.  
  84.                       <form action="{% url 'share:create_review' script.id %}" method="post">
  85.                       {% csrf_token %}
  86.  
  87.                       I found this solution to be:
  88.                       <!-- https://versions.bulma.io/0.7.1/documentation/form/radio/  -->
  89.                       <span class="control">
  90.                         <label class="radio"> <input type="radio" value="confusing" name="stars"> Confusing </label>
  91.                         <label class="radio"> <input type="radio" value="clear" name="stars"> Clear </label>
  92.                         <label class="radio"> <input type="radio" value="outstanding" name="stars"> Outstanding </label>
  93.                       </span>
  94.  
  95.                     <!-- http://versions.bulma.io/0.7.1/documentation/form/textarea/ -->
  96.                     <div class="field"> <div class="control"> <textarea class="textarea is-warning" name="feedback"
  97.                        placeholder="e.g. thank you for writing this solution, I was wondering if ..."></textarea></div>
  98.                     </div>
  99.  
  100.                     <div class="field"> <div class="control"> <button class="button is-success is-outlined" type="submit">
  101.                                                               Post review </button>&nbsp; </div>
  102.                     </div>
  103.  
  104.                 </form>
  105.  
  106.               {% endif %}
  107.  
  108.         </div>
  109.     </div>
  110. </div> <!-- column -->
  111.  
  112. <!-- Module 10 This column is to list all the reviews for this script -->
  113. <!-- Add recent reviews on the right column -->
  114. <div class="column is-one-quarter">
  115.  
  116. <br><br>
  117.   <h2 class="title is-4">Reviews</h2>
  118.           <div class="box">
  119.           <div class="content">
  120.           {% if reviews %}
  121.             {% for r in reviews %}
  122.                   {% if r.stars == 1 %} Confusing
  123.                   {% elif r.stars == 2 %} Clear
  124.                   {% elif r.stars == 3 %} Outstanding
  125.                   {% endif %}
  126.                   by {{r.coder.user.username}} <br>
  127.                   {{ r.feedback }}<br>
  128.  
  129.                   {% if r.coder.user.id == user.id %}
  130.                   <form action="{% url 'share:delete_review' r.id %}" method="post">
  131.                       {% csrf_token %}
  132.                        <button class="button is-danger is-outlined" type="submit" name="delete" value="Delete">
  133.                          Delete My Review</button>&nbsp;
  134.  
  135.                   </form>
  136.  
  137.                 {% endif %}
  138.               </div>
  139.             {% endfor %}
  140.           {% else %}
  141.           No reviews yet!
  142.           {% endif %}
  143.  
  144.  
  145. </div>
  146.  
  147. </div>
  148.  
  149. </div> <!-- columns -->
  150.  
  151.  
  152.  
  153.  
  154. {% endblock content %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement