euscanwww: Watched herds/maintainers/categories panel
* Refactored templates and templatetags * Added unfavourite views * Added button to favourite/unfavourite package * Panel for showing favourited objects Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
		| @@ -58,7 +58,7 @@ def _run_in_chunks(task, iterable, n=32): | |||||||
|         ]) |         ]) | ||||||
|         result = job.apply_async() |         result = job.apply_async() | ||||||
|         # TODO: understand why this causes timeout |         # TODO: understand why this causes timeout | ||||||
|         output.extend(list(result.join(timeout=3600))) |         #output.extend(list(result.join(timeout=3600))) | ||||||
|     return output |     return output | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ | |||||||
|                 <ul class="submenu"> |                 <ul class="submenu"> | ||||||
|                   <li><a href="{% url "accounts_categories" %}">Categories</a></li> |                   <li><a href="{% url "accounts_categories" %}">Categories</a></li> | ||||||
|                   <li><a href="{% url "accounts_herds" %}">Herds</a></li> |                   <li><a href="{% url "accounts_herds" %}">Herds</a></li> | ||||||
|                   <li><a href="{% url "accounts_maintainers" %}">Maintainer profiles</a></li> |                   <li><a href="{% url "accounts_maintainers" %}">Maintainers</a></li> | ||||||
|                   <li><a href="{% url "accounts_packages" %}">Packages</a></li> |                   <li><a href="{% url "accounts_packages" %}">Packages</a></li> | ||||||
|                 </ul> |                 </ul> | ||||||
|                 <li><a href="{% url "django.contrib.auth.views.logout" %}">Logout</a></li> |                 <li><a href="{% url "django.contrib.auth.views.logout" %}">Logout</a></li> | ||||||
|   | |||||||
							
								
								
									
										32
									
								
								euscanwww/djeuscan/templates/euscan/_categories_table.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								euscanwww/djeuscan/templates/euscan/_categories_table.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | |||||||
|  | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
|  | <table id="table" class="display"> | ||||||
|  |   <thead> | ||||||
|  |     <th>Category</th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> | ||||||
|  |     {% if extras %} | ||||||
|  |     <th>Graphs</th> | ||||||
|  |     {% endif %} | ||||||
|  |   </thead> | ||||||
|  |   <tbody> | ||||||
|  |   {% for category in categories %} | ||||||
|  |   <tr> | ||||||
|  |     <td> | ||||||
|  |       <a href="{% url "category" category.category %}">{{ category.category }}</a> | ||||||
|  |       {% package_bar category %} | ||||||
|  |     </td> | ||||||
|  |     {% package_cols category %} | ||||||
|  |     {% if extras %} | ||||||
|  |     <td> | ||||||
|  |       <img src="{% url "chart_category" category.category 'packages-monthly-small' %}" /> | ||||||
|  |       <img src="{% url "chart_category" category.category 'versions-monthly-small' %}" /> | ||||||
|  |     </td> | ||||||
|  |     {% endif %} | ||||||
|  |   </tr> | ||||||
|  |   {% endfor %} | ||||||
|  |   </tbody> | ||||||
|  | </table> | ||||||
							
								
								
									
										34
									
								
								euscanwww/djeuscan/templates/euscan/_herds_table.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								euscanwww/djeuscan/templates/euscan/_herds_table.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
|  | <table id="table" class="display"> | ||||||
|  |   <thead> | ||||||
|  |     <th>Herd</th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> | ||||||
|  |     {% if extras %} | ||||||
|  |     <th>Graphs</th> | ||||||
|  |     {% endif %} | ||||||
|  |   </thead> | ||||||
|  |   <tbody> | ||||||
|  |   {% for herd in herds %} | ||||||
|  |     <tr> | ||||||
|  |       <td> | ||||||
|  |         <a href="{% url "herd" herd.herds__herd %}"> | ||||||
|  |           {{ herd.herds__herd }} | ||||||
|  |         </a> | ||||||
|  |         {% package_bar herd %} | ||||||
|  |       </td> | ||||||
|  |       {% package_cols herd %} | ||||||
|  |       {% if extras %} | ||||||
|  |         <td> | ||||||
|  |           <img src="{% url "chart_herd" herd.herds__herd 'packages-monthly-small' %}" /> | ||||||
|  |           <img src="{% url "chart_herd" herd.herds__herd 'versions-monthly-small' %}" /> | ||||||
|  |         </td> | ||||||
|  |       {% endif %} | ||||||
|  |     </tr> | ||||||
|  |   {% endfor %} | ||||||
|  |   </tbody> | ||||||
|  | </table> | ||||||
							
								
								
									
										40
									
								
								euscanwww/djeuscan/templates/euscan/_maintainers_table.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								euscanwww/djeuscan/templates/euscan/_maintainers_table.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | |||||||
|  | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
|  | <table id="table" class="display"> | ||||||
|  |   <thead> | ||||||
|  |     <th>Maintainer</th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> | ||||||
|  |     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> | ||||||
|  |     {% if extras %} | ||||||
|  |       <th>Graphs</th> | ||||||
|  |     {% endif %} | ||||||
|  |   </thead> | ||||||
|  |   <tbody> | ||||||
|  |   {% for maintainer in maintainers %} | ||||||
|  |     <tr> | ||||||
|  |       <td> | ||||||
|  |         <a href="{% url "maintainer" maintainer.maintainers__id %}"> | ||||||
|  |           {% if maintainer.maintainers__name != maintainer.maintainers__email %} | ||||||
|  |             {{ maintainer.maintainers__name }} <{{ maintainer.maintainers__email }}> | ||||||
|  |           {% else %} | ||||||
|  |             {{ maintainer.maintainers__name }} | ||||||
|  |           {% endif %} | ||||||
|  |         </a> | ||||||
|  |         {% package_bar maintainer %} | ||||||
|  |       </td> | ||||||
|  |       {% package_cols maintainer %} | ||||||
|  |  | ||||||
|  |       {% if extras %} | ||||||
|  |         <td> | ||||||
|  |           <img src="{% url "chart_maintainer" maintainer.maintainers__id 'packages-monthly-small' %}" /> | ||||||
|  |           <img src="{% url "chart_maintainer" maintainer.maintainers__id 'versions-monthly-small' %}" /> | ||||||
|  |         </td> | ||||||
|  |       {% endif %} | ||||||
|  |  | ||||||
|  |     </tr> | ||||||
|  |   {% endfor %} | ||||||
|  |   </tbody> | ||||||
|  | </table> | ||||||
| @@ -1,4 +1,4 @@ | |||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load mul %} | {% load mul %} | ||||||
| {% load sub %} | {% load sub %} | ||||||
| {% load div %} | {% load div %} | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load sub %} | {% load sub %} | ||||||
| {% load div %} | {% load div %} | ||||||
| {% load mul %} | {% load mul %} | ||||||
|   | |||||||
| @@ -1,11 +1,15 @@ | |||||||
| {% extends "_base.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   {{ block.super }} - My categories |   {{ block.super }} - Watched categories | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
|   <h2>Welcome {{ user }}</h2> |   <h2>Watched categories</h2> | ||||||
|  |  | ||||||
|  |   {% categories_table categories %} | ||||||
|  |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,11 +1,14 @@ | |||||||
| {% extends "_base.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   {{ block.super }} - My herds |   {{ block.super }} - Watched herds | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
|   <h2>Welcome {{ user }}</h2> |   <h2>Watched herds</h2> | ||||||
|  |  | ||||||
|  |   {% herds_table herds %} | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,11 +1,14 @@ | |||||||
| {% extends "_base.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   {{ block.super }} - My maintainer profiles |   {{ block.super }} - Watched maintainers | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
|   <h2>Welcome {{ user }}</h2> |   <h2>Watched maintainers</h2> | ||||||
|  |  | ||||||
|  |   {% maintainers_table maintainers %} | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,15 +1,15 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   {{ block.super }} - My packages |   {{ block.super }} - Watched packages | ||||||
| {% endblock %} | {% endblock %} | ||||||
|  |  | ||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
|   <h2>My Packages</h2> |   <h2>Watched packages</h2> | ||||||
|  |  | ||||||
|   {% packages packages %} |   {% packages packages %} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| @@ -10,33 +10,6 @@ | |||||||
| {% block content %} | {% block content %} | ||||||
| <h2>Categories</h2> | <h2>Categories</h2> | ||||||
|  |  | ||||||
| <table id="table" class="display"> | {% categories_table categories request.GET.extras %} | ||||||
|   <thead> |  | ||||||
|     <th>Category</th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> |  | ||||||
|     {% if request.GET.extras %} |  | ||||||
|     <th>Graphs</th> |  | ||||||
|     {% endif %} |  | ||||||
|   </thead> |  | ||||||
|   <tbody> |  | ||||||
|   {% for category in categories %} |  | ||||||
|   <tr> |  | ||||||
|     <td> |  | ||||||
|       <a href="{% url "category" category.category %}">{{ category.category }}</a> |  | ||||||
|       {% package_bar category %} |  | ||||||
|     </td> |  | ||||||
|     {% package_cols category %} |  | ||||||
|     {% if request.GET.extras %} |  | ||||||
|     <td> |  | ||||||
|       <img src="{% url "chart_category" category.category 'packages-monthly-small' %}" /> |  | ||||||
|       <img src="{% url "chart_category" category.category 'versions-monthly-small' %}" /> |  | ||||||
|     </td> |  | ||||||
|     {% endif %} |  | ||||||
|   </tr> |  | ||||||
|   {% endfor %} |  | ||||||
|   </tbody> |  | ||||||
| </table> |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| @@ -9,35 +9,7 @@ | |||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
| <h2>Herds</h2> | <h2>Herds</h2> | ||||||
| <table id="table" class="display"> |  | ||||||
|   <thead> | {% herds_table herds request.GET.extras %} | ||||||
|     <th>Herd</th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> |  | ||||||
|     {% if request.GET.extras %} |  | ||||||
|     <th>Graphs</th> |  | ||||||
|     {% endif %} |  | ||||||
|   </thead> |  | ||||||
|   <tbody> |  | ||||||
|   {% for herd in herds %} |  | ||||||
|     <tr> |  | ||||||
|       <td> |  | ||||||
|         <a href="{% url "herd" herd.herds__herd %}"> |  | ||||||
|           {{ herd.herds__herd }} |  | ||||||
|         </a> |  | ||||||
|         {% package_bar herd %} |  | ||||||
|       </td> |  | ||||||
|       {% package_cols herd %} |  | ||||||
|       {% if request.GET.extras %} |  | ||||||
|         <td> |  | ||||||
|           <img src="{% url "chart_herd" herd.herds__herd 'packages-monthly-small' %}" /> |  | ||||||
|           <img src="{% url "chart_herd" herd.herds__herd 'versions-monthly-small' %}" /> |  | ||||||
|         </td> |  | ||||||
|       {% endif %} |  | ||||||
|     </tr> |  | ||||||
|   {% endfor %} |  | ||||||
|   </tbody> |  | ||||||
| </table> |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| @@ -9,41 +9,7 @@ | |||||||
|  |  | ||||||
| {% block content %} | {% block content %} | ||||||
| <h2>Maintainers</h2> | <h2>Maintainers</h2> | ||||||
| <table id="table" class="display"> |  | ||||||
|   <thead> |  | ||||||
|     <th>Maintainer</th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/gentoo-icon.png" alt="gentoo" title="Versions in Gentoo" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/overlay-icon.png" alt="overlays" title="Versions in Overlays" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Versions only upstream" /></th> |  | ||||||
|     <th><img src="{{ STATIC_URL }}img/freshness-icon.png" title="Freshness" /></th> |  | ||||||
|     {% if request.GET.extras %} |  | ||||||
|       <th>Graphs</th> |  | ||||||
|     {% endif %} |  | ||||||
|   </thead> |  | ||||||
|   <tbody> |  | ||||||
|   {% for maintainer in maintainers %} |  | ||||||
|     <tr> |  | ||||||
|       <td> |  | ||||||
|         <a href="{% url "maintainer" maintainer.maintainers__id %}"> |  | ||||||
|           {% if maintainer.maintainers__name != maintainer.maintainers__email %} |  | ||||||
|             {{ maintainer.maintainers__name }} <{{ maintainer.maintainers__email }}> |  | ||||||
|           {% else %} |  | ||||||
|             {{ maintainer.maintainers__name }} |  | ||||||
|           {% endif %} |  | ||||||
|         </a> |  | ||||||
|         {% package_bar maintainer %} |  | ||||||
|       </td> |  | ||||||
|       {% package_cols maintainer %} |  | ||||||
|  |  | ||||||
|       {% if request.GET.extras %} | {% maintainers_table maintainers request.GET.extras %} | ||||||
|         <td> |  | ||||||
|           <img src="{% url "chart_maintainer" maintainer.maintainers__id 'packages-monthly-small' %}" /> |  | ||||||
|           <img src="{% url "chart_maintainer" maintainer.maintainers__id 'versions-monthly-small' %}" /> |  | ||||||
|         </td> |  | ||||||
|       {% endif %} |  | ||||||
|  |  | ||||||
|     </tr> |  | ||||||
|   {% endfor %} |  | ||||||
|   </tbody> |  | ||||||
| </table> |  | ||||||
| {% endblock %} | {% endblock %} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| {{ block.super }} - Overlay: {{ overlay }} | {{ block.super }} - Overlay: {{ overlay }} | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
| {% load url from future %} | {% load url from future %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
|   | |||||||
| @@ -31,9 +31,12 @@ | |||||||
|     <button class="refresh-button" data-package="{{ package.category }}/{{ package.name }}"> |     <button class="refresh-button" data-package="{{ package.category }}/{{ package.name }}"> | ||||||
|       Refresh |       Refresh | ||||||
|     </button> |     </button> | ||||||
|     <button class="favourite-button" data-url="{% url "favourite_package" package.category package.name %}"> |     <button class="favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_package" package.category package.name %}"> | ||||||
|       Add to favourites |       Add to favourites | ||||||
|     </button> |     </button> | ||||||
|  |     <button class="unfavourite-button {% if not favourited %}hide{% endif %}" data-url="{% url "unfavourite_package" package.category package.name %}"> | ||||||
|  |       Remove from favourites | ||||||
|  |     </button> | ||||||
|   {% endif %} |   {% endif %} | ||||||
| </h2> | </h2> | ||||||
| <dl> | <dl> | ||||||
| @@ -151,7 +154,15 @@ | |||||||
|  |  | ||||||
|   $(".favourite-button").click(function() { |   $(".favourite-button").click(function() { | ||||||
|     $.post($(this).data("url"), function() { |     $.post($(this).data("url"), function() { | ||||||
|       alert("Favourited!"); |       $(".unfavourite-button").removeClass("hide"); | ||||||
|  |       $(".favourite-button").addClass("hide"); | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   $(".unfavourite-button").click(function() { | ||||||
|  |     $.post($(this).data("url"), function() { | ||||||
|  |       $(".favourite-button").removeClass("hide"); | ||||||
|  |       $(".unfavourite-button").addClass("hide"); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
| </script> | </script> | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| {% extends "euscan/_datatable.html" %} | {% extends "euscan/_datatable.html" %} | ||||||
|  |  | ||||||
| {% load packages %} | {% load euscan %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| {{ block.super }} - World Scan | {{ block.super }} - World Scan | ||||||
|   | |||||||
							
								
								
									
										49
									
								
								euscanwww/djeuscan/templatetags/euscan.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								euscanwww/djeuscan/templatetags/euscan.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | |||||||
|  | from django import template | ||||||
|  | from django.conf import settings | ||||||
|  |  | ||||||
|  | register = template.Library() | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_packages.html', takes_context=True) | ||||||
|  | def packages(context, pkgs): | ||||||
|  |     context['packages'] = pkgs | ||||||
|  |     return context | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_package_cols.html', takes_context=True) | ||||||
|  | def package_cols(context, infos): | ||||||
|  |     context['infos'] = infos | ||||||
|  |     return context | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_package_bar.html', takes_context=True) | ||||||
|  | def package_bar(context, infos): | ||||||
|  |     context['infos'] = infos | ||||||
|  |     return context | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_categories_table.html') | ||||||
|  | def categories_table(categories, extras=False): | ||||||
|  |     return { | ||||||
|  |         "categories": categories, | ||||||
|  |         "extras": extras, | ||||||
|  |         "STATIC_URL": settings.STATIC_URL, | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_herds_table.html') | ||||||
|  | def herds_table(herds, extras=False): | ||||||
|  |     return { | ||||||
|  |         "herds": herds, | ||||||
|  |         "extras": extras, | ||||||
|  |         "STATIC_URL": settings.STATIC_URL, | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @register.inclusion_tag('euscan/_maintainers_table.html') | ||||||
|  | def maintainers_table(maintainers, extras=False): | ||||||
|  |     return { | ||||||
|  |         "maintainers": maintainers, | ||||||
|  |         "extras": extras, | ||||||
|  |         "STATIC_URL": settings.STATIC_URL, | ||||||
|  |     } | ||||||
| @@ -1,21 +0,0 @@ | |||||||
| from django import template |  | ||||||
|  |  | ||||||
| register = template.Library() |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @register.inclusion_tag('euscan/_packages.html', takes_context=True) |  | ||||||
| def packages(context, pkgs): |  | ||||||
|     context['packages'] = pkgs |  | ||||||
|     return context |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @register.inclusion_tag('euscan/_package_cols.html', takes_context=True) |  | ||||||
| def package_cols(context, infos): |  | ||||||
|     context['infos'] = infos |  | ||||||
|     return context |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @register.inclusion_tag('euscan/_package_bar.html', takes_context=True) |  | ||||||
| def package_bar(context, infos): |  | ||||||
|     context['infos'] = infos |  | ||||||
|     return context |  | ||||||
| @@ -18,6 +18,9 @@ package_patterns = patterns('djeuscan.views', | |||||||
|         'package', name="package"), |         'package', name="package"), | ||||||
|     url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/favourite$', |     url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/favourite$', | ||||||
|         'favourite_package', name="favourite_package"), |         'favourite_package', name="favourite_package"), | ||||||
|  |     url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/' | ||||||
|  |          'unfavourite$'), | ||||||
|  |         'unfavourite_package', name="unfavourite_package"), | ||||||
| ) | ) | ||||||
|  |  | ||||||
| categories_patterns = patterns('djeuscan.views', | categories_patterns = patterns('djeuscan.views', | ||||||
| @@ -29,6 +32,8 @@ categories_patterns = patterns('djeuscan.views', | |||||||
|         'chart_category', name="chart_category"), |         'chart_category', name="chart_category"), | ||||||
|     url(r'^(?P<category>[\w+][\w+.-]*)/favourite$', |     url(r'^(?P<category>[\w+][\w+.-]*)/favourite$', | ||||||
|         'favourite_category', name="favourite_category"), |         'favourite_category', name="favourite_category"), | ||||||
|  |     url(r'^(?P<category>[\w+][\w+.-]*)/unfavourite$', | ||||||
|  |         'unfavourite_category', name="unfavourite_category"), | ||||||
|     url(r'^$', 'categories', name="categories"), |     url(r'^$', 'categories', name="categories"), | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -39,6 +44,8 @@ herds_patterns = patterns('djeuscan.views', | |||||||
|         'chart_herd', name="chart_herd"), |         'chart_herd', name="chart_herd"), | ||||||
|     url(r'^(?P<herd>[\@\{\}\w+.-]*)/favourite$', 'favourite_herd', |     url(r'^(?P<herd>[\@\{\}\w+.-]*)/favourite$', 'favourite_herd', | ||||||
|         name="favourite_herd"), |         name="favourite_herd"), | ||||||
|  |     url(r'^(?P<herd>[\@\{\}\w+.-]*)/unfavourite$', 'unfavourite_herd', | ||||||
|  |         name="unfavourite_herd"), | ||||||
|     url(r'^$', 'herds', name="herds"), |     url(r'^$', 'herds', name="herds"), | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -50,6 +57,8 @@ maintainers_patterns = patterns('djeuscan.views', | |||||||
|         'chart_maintainer', name="chart_maintainer"), |         'chart_maintainer', name="chart_maintainer"), | ||||||
|     url(r'^(?P<maintainer_id>\d+)/favourite$', |     url(r'^(?P<maintainer_id>\d+)/favourite$', | ||||||
|         'favourite_maintainer', name="favourite_maintainer"), |         'favourite_maintainer', name="favourite_maintainer"), | ||||||
|  |     url(r'^(?P<maintainer_id>\d+)/unfavourite$', | ||||||
|  |         'unfavourite_maintainer', name="unfavourite_maintainer"), | ||||||
|     url(r'^$', 'maintainers', name="maintainers"), |     url(r'^$', 'maintainers', name="maintainers"), | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -167,13 +167,23 @@ def package(request, category, package): | |||||||
|     except EuscanResult.DoesNotExist: |     except EuscanResult.DoesNotExist: | ||||||
|         last_scan = None |         last_scan = None | ||||||
|  |  | ||||||
|  |     favourited = False | ||||||
|  |     if request.user.is_authenticated(): | ||||||
|  |         try: | ||||||
|  |             PackageAssociation.objects.get(user=request.user, package=package) | ||||||
|  |         except PackageAssociation.DoesNotExist: | ||||||
|  |             pass | ||||||
|  |         else: | ||||||
|  |             favourited = True | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         'package': package, |         'package': package, | ||||||
|         'packaged': packaged, |         'packaged': packaged, | ||||||
|         'upstream': upstream, |         'upstream': upstream, | ||||||
|         'log': log, |         'log': log, | ||||||
|         'vlog': vlog, |         'vlog': vlog, | ||||||
|         'last_scan': last_scan |         'last_scan': last_scan, | ||||||
|  |         'favourited': favourited, | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -299,19 +309,25 @@ def accounts_index(request): | |||||||
| @login_required | @login_required | ||||||
| @render_to('euscan/accounts/categories.html') | @render_to('euscan/accounts/categories.html') | ||||||
| def accounts_categories(request): | def accounts_categories(request): | ||||||
|     return {} |     categories = [obj.category for obj in | ||||||
|  |                   CategoryAssociation.objects.filter(user=request.user)] | ||||||
|  |     return {"categories": categories} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @render_to('euscan/accounts/herds.html') | @render_to('euscan/accounts/herds.html') | ||||||
| def accounts_herds(request): | def accounts_herds(request): | ||||||
|     return {} |     herds = [obj.herd for obj in | ||||||
|  |              HerdAssociation.objects.filter(user=request.user)] | ||||||
|  |     return {"herds": herds} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @render_to('euscan/accounts/maintainers.html') | @render_to('euscan/accounts/maintainers.html') | ||||||
| def accounts_maintainers(request): | def accounts_maintainers(request): | ||||||
|     return {} |     maintainers = [obj.maintainer for obj in | ||||||
|  |                    MaintainerAssociation.objects.filter(user=request.user)] | ||||||
|  |     return {"maintainers": maintainers} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @@ -333,6 +349,18 @@ def favourite_package(request, category, package): | |||||||
|     return {"success": created} |     return {"success": created} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @login_required | ||||||
|  | @require_POST | ||||||
|  | @ajax_request | ||||||
|  | def unfavourite_package(request, category, package): | ||||||
|  |     package = get_object_or_404(Package, category=category, name=package) | ||||||
|  |     obj = get_object_or_404( | ||||||
|  |         PackageAssociation, package=package, user=request.user | ||||||
|  |     ) | ||||||
|  |     obj.delete() | ||||||
|  |     return {"success": True} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @require_POST | @require_POST | ||||||
| @ajax_request | @ajax_request | ||||||
| @@ -344,6 +372,18 @@ def favourite_herd(request, herd): | |||||||
|     return {"success": created} |     return {"success": created} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @login_required | ||||||
|  | @require_POST | ||||||
|  | @ajax_request | ||||||
|  | def unfavourite_herd(request, herd): | ||||||
|  |     herd = get_object_or_404(Herd, herd=herd) | ||||||
|  |     obj = get_object_or_404( | ||||||
|  |         HerdAssociation, herd=herd, user=request.user | ||||||
|  |     ) | ||||||
|  |     obj.delete() | ||||||
|  |     return {"success": True} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @require_POST | @require_POST | ||||||
| @ajax_request | @ajax_request | ||||||
| @@ -355,6 +395,18 @@ def favourite_maintainer(request, maintainer_id): | |||||||
|     return {"success": created} |     return {"success": created} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @login_required | ||||||
|  | @require_POST | ||||||
|  | @ajax_request | ||||||
|  | def unfavourite_maintainer(request, maintainer_id): | ||||||
|  |     maintainer = get_object_or_404(Maintainer, pk=maintainer_id) | ||||||
|  |     obj = get_object_or_404( | ||||||
|  |         MaintainerAssociation, maintainer=maintainer, user=request.user | ||||||
|  |     ) | ||||||
|  |     obj.delete() | ||||||
|  |     return {"success": True} | ||||||
|  |  | ||||||
|  |  | ||||||
| @login_required | @login_required | ||||||
| @require_POST | @require_POST | ||||||
| @ajax_request | @ajax_request | ||||||
| @@ -368,3 +420,14 @@ def favourite_category(request, category): | |||||||
|         user=request.user, category=category |         user=request.user, category=category | ||||||
|     ) |     ) | ||||||
|     return {"success": created} |     return {"success": created} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @login_required | ||||||
|  | @require_POST | ||||||
|  | @ajax_request | ||||||
|  | def unfavourite_category(request, category): | ||||||
|  |     obj = get_object_or_404( | ||||||
|  |         CategoryAssociation, user=request.user, category=category | ||||||
|  |     ) | ||||||
|  |     obj.delete() | ||||||
|  |     return {"success": True} | ||||||
|   | |||||||
| @@ -119,68 +119,66 @@ a:hover, a:active | |||||||
|  |  | ||||||
| /* | /* | ||||||
| code, pre{ | code, pre{ | ||||||
| 	background-color:transparent; |     background-color:transparent; | ||||||
| 	font-family:"Courier New",Courier,monospace; |     font-family:"Courier New",Courier,monospace; | ||||||
| 	font-size:small; |     font-size:small; | ||||||
| } | } | ||||||
| */ | */ | ||||||
|  |  | ||||||
| a{ | a{ | ||||||
| 	color: #3F4C66; |     color: #3F4C66; | ||||||
| } | } | ||||||
|  |  | ||||||
| a:link, a:visited, a:active { | a:link, a:visited, a:active { | ||||||
| 	color: #3F4C66; |     color: #3F4C66; | ||||||
| 	text-decoration: none; |     text-decoration: none; | ||||||
| } | } | ||||||
| a:hover { | a:hover { | ||||||
| 	color: #4C5C7B; |     color: #4C5C7B; | ||||||
| 	text-decoration: underline; |     text-decoration: underline; | ||||||
| } | } | ||||||
|  |  | ||||||
| abbr:hover { | abbr:hover { | ||||||
| 	text-decoration: underline; |     text-decoration: underline; | ||||||
| } | } | ||||||
|  |  | ||||||
| pre{ | pre{ | ||||||
| 	border-left:5px solid; |     border-left:5px solid; | ||||||
| 	padding:0.5em 1em; |     padding:0.5em 1em; | ||||||
| 	margin-left:2em; |     margin-left:2em; | ||||||
| } | } | ||||||
|  |  | ||||||
| dt { | dt { | ||||||
| 	font-weight: bold; |     font-weight: bold; | ||||||
| } | } | ||||||
|  |  | ||||||
| dd { | dd { | ||||||
| 	border-left: 1px solid #ccc; |     border-left: 1px solid #ccc; | ||||||
| 	margin: 5px; |     margin: 5px; | ||||||
| 	padding: 5px; |     padding: 5px; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| h1 { | h1 { | ||||||
|         color: #000; |     color: #000; | ||||||
| 	width: 20em; |     width: 20em; | ||||||
| 	margin-left: auto; |     margin-left: auto; | ||||||
| 	margin-right: auto; |     margin-right: auto; | ||||||
| } | } | ||||||
|  |  | ||||||
| .ok { | .ok { | ||||||
| 	color:#15B100; |     color:#15B100; | ||||||
| } | } | ||||||
|  |  | ||||||
| hr | hr { | ||||||
| { |     margin: 0.3em 1em 0.3em 1em; | ||||||
|   margin: 0.3em 1em 0.3em 1em; |     height: 1px; | ||||||
|   height: 1px; |     border: #bcbcbc dashed; | ||||||
|   border: #bcbcbc dashed; |     border-width: 0 0 1px 0; | ||||||
|   border-width: 0 0 1px 0; | } | ||||||
|   } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| table | table { | ||||||
| { |  | ||||||
|     max-width: 60em; |     max-width: 60em; | ||||||
|     /* width: 50%; */ |     /* width: 50%; */ | ||||||
|     border-collapse: collapse; |     border-collapse: collapse; | ||||||
| @@ -191,27 +189,24 @@ table | |||||||
|     text-align: left; |     text-align: left; | ||||||
| } | } | ||||||
|  |  | ||||||
| td | td { | ||||||
| { |     vertical-align: top; | ||||||
|   vertical-align: top; | } | ||||||
|   } |  | ||||||
|  |  | ||||||
| th | th { | ||||||
| { |     font-size: 0.8em; | ||||||
|   font-size: 0.8em; |     text-align: center; | ||||||
|   text-align: center; |     border-bottom: 3px solid; | ||||||
|   border-bottom: 3px solid; | } | ||||||
|  } |  | ||||||
|  |  | ||||||
| #footer | #footer { | ||||||
| { |  | ||||||
|     background: #8076A1; |     background: #8076A1; | ||||||
|     font-size: 0.8em; |     font-size: 0.8em; | ||||||
|     width: 100%; |     width: 100%; | ||||||
|     margin: 0; |     margin: 0; | ||||||
|     margin-top: 10px; |     margin-top: 10px; | ||||||
|     color: #FFF; |     color: #FFF; | ||||||
|  } | } | ||||||
|  |  | ||||||
| #footer p { | #footer p { | ||||||
|     text-align: right; |     text-align: right; | ||||||
| @@ -220,33 +215,31 @@ th | |||||||
|  |  | ||||||
| .err,.ok,.inf | .err,.ok,.inf | ||||||
| { | { | ||||||
|   margin: 5px; |     margin: 5px; | ||||||
|   margin-left: auto; |     margin-left: auto; | ||||||
|   margin-right: auto; |     margin-right: auto; | ||||||
|   width: 70%; |     width: 70%; | ||||||
|   font-weight:bold; |     font-weight:bold; | ||||||
|   border: 1px dotted #5682AD; |     border: 1px dotted #5682AD; | ||||||
|   } | } | ||||||
|  |  | ||||||
| .added { | .added { | ||||||
|   color: #262; |     color: #262; | ||||||
| } | } | ||||||
|  |  | ||||||
| .removed { | .removed { | ||||||
|   color: #F00; |     color: #F00; | ||||||
| } | } | ||||||
|  |  | ||||||
| .err | .err { | ||||||
| { |     border-color: #F00; | ||||||
|   border-color: #F00; |     color: #F00; | ||||||
|   color: #F00; | } | ||||||
|  } |  | ||||||
|  |  | ||||||
| .ok | .ok { | ||||||
| { |     border-color: #262; | ||||||
|   border-color: #262; |     color: #262; | ||||||
|   color: #262; | } | ||||||
|   } |  | ||||||
|  |  | ||||||
| .logo { | .logo { | ||||||
|     float: right; |     float: right; | ||||||
| @@ -284,3 +277,7 @@ th | |||||||
|     max-height: 100pt; |     max-height: 100pt; | ||||||
|     overflow: auto; |     overflow: auto; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .hide { | ||||||
|  |     display: none; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user