list_listings.html 2.4 KB
Newer Older
Daniel W Bond's avatar
Daniel W Bond committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{% extends 'layouts/base.html' %}

{% block title %}
SRCT Bookshare • Latest Listings
{% endblock %}

{% block content %}

<div class="page-header" id="banner">
  <div class="row">
    <div class="col-lg-12">
      <h1 class="text-center"><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
      <p class="lead text-center"><strong>Latest Listings</strong></p>
    </div>
  </div>
</div>

{% if listings %}

  <div class="row">
    <div class="col-md-10 col-md-offset-1 text-center">
    <p>Want to <strong><a href="/search">search</a></strong> for something specific?</p>
    </div>
  </div>

  <div class="row">

    {% comment %}
      Essentially the logic here is to create 3 columns where
      there are n rows in each.

      The first conditional will add an initial column tag if the loop is
      beginning a new column. The second conditional adds a closing column
      tag when the loop ends a column.
    {% endcomment %}

    {% for listing in listings %}

      {% if forloop.counter|add:-1|divisibleby:rows %}
      <div class="col-md-4">
      {% endif %}

        {% include 'listing_preview_panel.html' %}

      {% if forloop.counter|add:rows|divisibleby:rows %}
      </div>
      {% endif %}

    {% endfor %}

  </div>

  <div class="row">
    <div class="col-lg-4 col-lg-offset-4">

      <ul class="pager">

        {% if listings.has_previous %}
          <li class="previous">
            <a href="?page={{ listings.previous_page_number }}">
              &larr; Newer
            </a>
          </li>
        {% else %}
          <li class="previous disabled">
            <a>
              &larr; Newer
            </a>
          </li>
        {% endif %}

        {% if listings.has_next %}
          <li class="next">
            <a href="?page={{ listings.next_page_number }}">
              Older &rarr;
            </a>
          </li>
        {% else %}
          <li class="next disabled">
            <a>
              Older &rarr;
            </a>
          </li>
        {% endif %}

      </ul>

    </div>
  </div>

{% else %}

  <div class="row">
    <div class="col-md-10 col-md-offset-1 text-center">
      <div class="panel panel-warning">
        <div class="panel-body">
          <h3>There aren't any books in the database!</h3>
          <p>
            Looks like you'll be the first to <a href="#">create one</a>!
          </p>
        </div>
      </div>
    </div>
  </div>

{% endif %}

{% endblock %}