search.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. {% extends '_base.html' %}
  2. {% load helpers %}
  3. {% load form_helpers %}
  4. {% block title %}Search{% endblock %}
  5. {% block content %}
  6. {% if request.GET.q %}
  7. {% include 'search_form.html' with search_form=form %}
  8. {% if results %}
  9. <div class="row">
  10. <div class="col-md-10">
  11. {% for obj_type in results %}
  12. <h3 id="{{ obj_type.name|lower }}">{{ obj_type.name|bettertitle }}</h3>
  13. {% include 'panel_table.html' with table=obj_type.table hide_paginator=True %}
  14. <a href="{{ obj_type.url }}" class="btn btn-primary pull-right">
  15. <span class="fa fa-arrow-right" aria-hidden="true"></span>
  16. {% if obj_type.table.page.has_next %}
  17. See all {{ obj_type.table.page.paginator.count }} results
  18. {% else %}
  19. Refine search
  20. {% endif %}
  21. </a>
  22. <div class="clearfix"></div>
  23. {% endfor %}
  24. </div>
  25. <div class="col-md-2" style="padding-top: 20px;">
  26. <div class="panel panel-default">
  27. <div class="panel-heading">
  28. <strong>Search Results</strong>
  29. </div>
  30. <div class="list-group">
  31. {% for obj_type in results %}
  32. <a href="#{{ obj_type.name|lower }}" class="list-group-item">
  33. {{ obj_type.name|bettertitle }}
  34. <span class="badge">{{ obj_type.table.page.paginator.count }}</span>
  35. </a>
  36. {% endfor %}
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. {% else %}
  42. <h3 class="text-muted text-center">No results found</h3>
  43. {% endif %}
  44. {% else %}
  45. <div class="row" style="margin-top: 150px;">
  46. <div class="col-sm-4 col-sm-offset-4">
  47. <form action="{% url 'search' %}" method="get" class="form form-horizontal">
  48. <div class="panel panel-default">
  49. <div class="panel-heading">
  50. <strong>Search</strong>
  51. </div>
  52. <div class="panel-body">
  53. {% render_form form %}
  54. </div>
  55. <div class="panel-footer text-right">
  56. <button type="submit" class="btn btn-primary">
  57. <span class="fa fa-search" aria-hidden="true"></span> Search
  58. </button>
  59. </div>
  60. </div>
  61. </form>
  62. </div>
  63. </div>
  64. {% endif %}
  65. {% endblock %}