detail_listing.html 10.4 KB
Newer Older
Daniel W Bond's avatar
Daniel W Bond committed
1 2 3
{% extends 'layouts/base.html' %}

{% block title %}
4
SRCT Bookshare • {{ listing.title }}
Daniel W Bond's avatar
Daniel W Bond committed
5
{% endblock title %}
Daniel W Bond's avatar
Daniel W Bond committed
6

7 8 9 10 11 12 13 14 15 16 17 18 19
{% block social_metadata %}
<meta property="og:title" content="{{ listing.title }}"/>
<meta property="og:type" content="book"/>
<meta property="og:url" content="{{ request.build_absolute_uri }}"/>
<meta property="og:image" content-"{{ listing.photo.url }}"/>
<meta property="books:author" content="{{ listing.author }}"/>
<meta property="books:isbn" content=" {{ listing.isbn }}"/>
{% if listing.year %}
<meta property="books:release_date" content="{{ listing.year }}"
{% endif %}

{% endblock social_metadata %}

Daniel W Bond's avatar
Daniel W Bond committed
20 21
{% block content %}

22 23
{% load crispy_forms_tags %}

24 25
{% load humanize %}

26
<!-- you can't actually dismiss this for some reason -->
Daniel W Bond's avatar
Daniel W Bond committed
27
{% if flag_count > 4 %}
Daniel W Bond's avatar
Daniel W Bond committed
28

Daniel W Bond's avatar
Daniel W Bond committed
29
{% block javascript %}
Daniel W Bond's avatar
Daniel W Bond committed
30
<script type="text/javascript">
Daniel W Bond's avatar
Daniel W Bond committed
31
    $(window).load(function(){
Daniel W Bond's avatar
Daniel W Bond committed
32 33 34
        $('#myModal').modal('show');
    });
</script>
Daniel W Bond's avatar
Daniel W Bond committed
35
{% endblock javascript %}
Daniel W Bond's avatar
Daniel W Bond committed
36 37

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h3 class="modal-title"><strong class="text-danger"><i class="fa fa-exclamation-triangle fa-fw"></i> Warning:</strong> This listing has been flagged!</h3>
      </div>
      <div class="modal-body text-center">
        {% for flag in flags %}
        <h4><strong>{{ flag.reason }}</strong> {{ flag.created|date:"M d, 'y P" }} <small>({{ flag.created|naturaltime }})</small></h4>
        {% endfor %}
      </div>
      <div class="modal-footer">
        <div class="text-center"><!-- not sure why this doesn't work in the above div... -->
        <!-- also, why is the dismissing not working... >__> -->
        <button type="button" class="btn btn-danger" data-dismiss="modal">Proceed</button>
        <a href="javascript:history.back()"><button type="button" class="btn btn-default">Get Me Out of Here</button></a>
        </div>
      </div>
    </div>
  </div>
</div>
{% endif %}

60
{% include 'messages.html' %}
61

62
{% if listing.cancelled %}
Daniel W Bond's avatar
Daniel W Bond committed
63 64 65
  <div class="row">
    <div class="col-lg-12">
      <div class="alert alert-danger text-center">
66
        <strong>This listing has been cancelled.</strong>
Daniel W Bond's avatar
Daniel W Bond committed
67 68 69
      </div>
    </div>
  </div>
70
{% elif listing.exchanged %}
Daniel W Bond's avatar
Daniel W Bond committed
71 72
  <div class="row">
    <div class="col-lg-12">
73 74
      {% if listing.winning_bid.bidder.user == request.user %}
      <div class="alert alert-success text-center">
75
        <strong>You exchanged this listing {{ listing.date_closed|timesince }} ago.</strong>
76
        {% if rating %}
77
          <strong><a href="{% url 'edit_rating' listing.slug rating.slug %}">Edit</a> <a href="{% url 'ratings' listing.poster.slug %}">your rating</a> of this exchange.</strong>
78
        {% else %}
79
          <strong>Rate your experience with {{ listing.poster.user.first_name }} <a href="{% url 'create_rating' listing.slug %}">here</a>.</strong>
80 81
        {% endif %}
      {% else %}
Daniel W Bond's avatar
Daniel W Bond committed
82
      <div class="alert alert-danger text-center">
83
        <strong>This listing has been exchanged.</strong>
84
      {% endif %}
Daniel W Bond's avatar
Daniel W Bond committed
85 86 87
      </div>
    </div>
  </div>
88
{% elif not listing.active %}
Daniel W Bond's avatar
Daniel W Bond committed
89 90
  <div class="row">
    <div class="col-lg-12">
91
      <div class="alert alert-warning text-center alert-dismissable">
Daniel W Bond's avatar
Daniel W Bond committed
92 93
        <button type="button" class="close" data-dismiss="alert"
        aria-hidden="true">&times;</button>
94
        Heads up, this listing is <strong>over a month old</strong> and we haven't seen the student who posted it around recently either. It may no longer be valid!
Daniel W Bond's avatar
Daniel W Bond committed
95 96 97 98 99
      </div>
    </div>
  </div>
{% endif %}

100 101
{% load trades_extras %}

102
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
103
  <div class="col-xs-8">
104 105 106 107
    <h1>
      <em><strong>{{ listing.title }}</strong></em>
    </h1>
  </div>
Daniel W Bond's avatar
Daniel W Bond committed
108
  <div class="col-xs-4 text-right">
109
    <h1 class="price">
110
      {% if listing.exchanged %}
111
        <small>Final</small> <strong>${{ listing.final_price }}</strong>
112
      {% else %}
113
        <small>Asking</small> <strong>${{ listing.price }}</strong>
114 115 116 117
      {% endif %}
    </h1>
  </div>
</div>
Daniel W Bond's avatar
Daniel W Bond committed
118

119
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
120
  <div class="col-xs-6">
121 122 123
    <h4>
      <small>by</small> {{ listing.author }}
      {% if listing.year %}
124
        ({{ listing.year|bc }})
125 126 127
      {% endif %}
    </h4>
  </div>
Daniel W Bond's avatar
Daniel W Bond committed
128
  <div class="col-xs-6 text-right">
129 130 131
    <h4><small>Listed</small> {{ listing.created|date:"M d, 'y P" }} <small>({{ listing.created|naturaltime }})</small></h4>
  </div>
</div>
Daniel W Bond's avatar
Daniel W Bond committed
132

133
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
134
  <div class="col-md-3 col-sm-6 col-xs-6">
135 136 137
      <h4><small>ISBN</small> {{ listing.isbn }}</h4>
  </div>

Daniel W Bond's avatar
Daniel W Bond committed
138
  <div class="col-md-2 col-sm-6 col-xs-6 small-text-right">
139 140
    <h4>
      {% if listing.edition %}
141
        {{ listing.edition|ordinal }}<small> edition</small>
142 143 144
      {% endif %}
    </h4>
  </div>
145

Daniel W Bond's avatar
Daniel W Bond committed
146
  <div class="col-md-3 col-sm-6 col-xs-6">
147
    {% if listing.course_abbr %}
Daniel Taylor's avatar
Daniel Taylor committed
148
      <h4><small>Course</small> {{ listing.course_abbr }}</h4>
149 150
    {% else %}
    {% endif %}
151 152
  </div>

Daniel W Bond's avatar
Daniel W Bond committed
153
  <div class="col-md-4 col-sm-6 col-xs-6 text-right">
154 155
    <h4><small>Posted by</small><a href="{% url 'profile' listing.poster.user.username %}"> {{ listing.poster.user.get_full_name }}</a>
    {% if request.user == listing.poster.user %}
156 157
    (Me)
    {% endif %}</h4>
Daniel W Bond's avatar
Daniel W Bond committed
158 159 160
  </div>
</div>

161
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
162
  <div class="col-md-3 col-sm-6 col-xs-6">
163 164 165
    <h4><small>Condition</small> {{ listing.condition }}</h4>
  </div>

Daniel W Bond's avatar
Daniel W Bond committed
166
  <div class="col-md-4 col-sm-6 col-xs-6 small-text-right">
167
    <h4><small>Access Code</small> {{ listing.access_code }}</h4>
168 169
  </div>

Daniel W Bond's avatar
Daniel W Bond committed
170
  <div class="col-md-5 text-right small-text-center">
171
  {% if request.user == listing.poster.user %}
172 173
  {% else %}
    {% if can_flag %}
174
    <h5><a href="{% url 'create_flag' listing.slug %}"><span class="label label-danger"><i class="fa fa-flag fa-fw fa-lg"></i> Flag</span></a></h5>
175
    {% else %}
176
    <h5><a href="{% url 'delete_flag' listing.slug flag_slug %}"><span class="label label-danger"><i class="fa fa-flag fa-fw fa-lg"></i>Remove Flag</span></a></h5>
177 178 179 180 181 182
    {% endif %}
  {% endif %}
  </div>
</div>

<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
183
  <div class="col-md-3 col-sm-6 col-xs-12">
Daniel W Bond's avatar
Daniel W Bond committed
184
    <div class="text-center">
Daniel W Bond's avatar
Daniel W Bond committed
185
      <a href="{{ listing.photo.url }}">
186
        <img src="{{ listing.photo.url  }}"
Daniel W Bond's avatar
Daniel W Bond committed
187 188 189 190 191
        alt="User submitted textbook photo" class="img-thumbnail" />
      </a>
    </div>
  </div>

Daniel W Bond's avatar
Daniel W Bond committed
192
  <div class="col-md-9 col-sm-6 col-xs-12">
193
    {% if listing.description %}
Daniel W Bond's avatar
Daniel W Bond committed
194 195
    <h4><small>Description/Comments</small>
      {{ listing.description }}
196 197
    {% else %}
    {% endif %}
Daniel W Bond's avatar
Daniel W Bond committed
198 199 200
  </div>
</div>

201
<div class="row text-center">
202
{% if request.user == listing.poster.user %}
203 204
  <div class="col-md-6 col-md-offset-3">
    <h3>
205
      {% if bid_count > 0 %}
206
        {% if not listing.exchanged and not listing.cancelled %}
207
        <span class="label label-default">
208
          <a href="{% url 'exchange_listing' listing.slug %}">Exchange</a>
209 210 211
        </a></span>
        {% elif not listing.cancelled %}
        <span class="label label-default">
Daniel W Bond's avatar
Daniel W Bond committed
212
          <a href="{% url 'unexchange_listing' listing.slug %}">Cancel Exchange</a>
213 214
       </span>
        {% endif %}
215 216
      {% endif %}
      &nbsp;
217
      {% if not listing.exchanged and not listing.cancelled %}
218 219 220 221 222
      <span class="label label-default">
        <a href="{% url 'edit_listing' listing.slug %}">Edit Listing</a>
      </span>
      {% endif %}
      &nbsp;
223
      {% if not listing.cancelled and not listing.exchanged %}
224 225 226
      <span class="label label-default">
        <a href="{% url 'cancel_listing' listing.slug %}">Cancel Listing</a>
      </span>
227
      {% elif listing.cancelled and not listing.exchanged %}
228 229 230 231 232 233
      <span class="label label-default">
        <a href="{% url 'reopen_listing' listing.slug %}">Reopen Listing</a>
      </span>
      {% endif %}
    </h3>
  </div>
234 235 236
</div>

{% else %}
Daniel W Bond's avatar
Daniel W Bond committed
237
  <div class="col-md-12">
238 239 240 241 242 243 244
    <div class="panel panel-default" style="margin-top:10px;">
      <div class="panel-heading">
        <h4 class="panel-title">
          <strong>Submit Your Bid</strong>
        </h4>
      </div>
      <div class="panel-body">
245
      {% if not listing.cancelled and not listing.exchanged %}
246 247 248
        <div class="row">
          {% crispy my_form %}
        </div>
249
      {% else %}
Daniel W Bond's avatar
Daniel W Bond committed
250
      <div class="col-md-12">
251 252 253
        <h5 class="text-center">This listing has been
          {% if listing.cancelled %}
          cancelled
254 255
          {% elif listing.exchanged %}
          exchanged
256 257 258
          {% endif %}
          and is no longer accepting bids.
        </h5>
259 260 261 262
      </div>
      {% endif %}
      </div>
    </div>
Daniel W Bond's avatar
Daniel W Bond committed
263 264 265 266
  </div>
</div>
{% endif %}

Daniel W Bond's avatar
Daniel W Bond committed
267
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
268
  <div class="col-md-12">
Daniel W Bond's avatar
Daniel W Bond committed
269 270
    <div class="panel panel-default" style="margin-top:10px;">
      <div class="panel-heading">
271
        <h4 class="panel-title text-center">
Daniel W Bond's avatar
Daniel W Bond committed
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
          <a data-toggle="collapse" href="#bids">
            Hide/Show Bids ({{ bid_count }})
          </a>
        </h4>
      </div>
      <div class="panel-body">

        {% if bids %}
        <div id="bids" class="panel-collapse collapse in">
        {% endif %}

        {% for bid in bids %}
        <!-- BID DISPLAY -->
          <div class="row">

Daniel W Bond's avatar
Daniel W Bond committed
287
            <div class="col-md-3 col-sm-6 col-xs-6 text-center">
288
              <h4><a href="{{ bid.bidder.get_absolute_url }}">
Daniel W Bond's avatar
Daniel W Bond committed
289 290
                {{ bid.bidder.user.first_name }}
                {{ bid.bidder.user.last_name }}
291
              </a></h4>
Daniel W Bond's avatar
Daniel W Bond committed
292 293
            </div>

Daniel W Bond's avatar
Daniel W Bond committed
294
            <div class="col-md-2 col-sm-6 col-xs-6 small-text-center">
295
              <h4><small>{{ bid.created|naturaltime }}</small></h4>
Daniel W Bond's avatar
Daniel W Bond committed
296 297
            </div>

Daniel W Bond's avatar
Daniel W Bond committed
298
            <div class="col-md-5 col-sm-6 col-xs-6 small-text-center">
299
              <h4><small>
Daniel W Bond's avatar
Daniel W Bond committed
300 301 302 303
              {% if bid.text %}
                {{ bid.text }}
              {% else %}
              {% endif %}
304
              </small></h4>
Daniel W Bond's avatar
Daniel W Bond committed
305 306
            </div>

Daniel W Bond's avatar
Daniel W Bond committed
307
            <div class="col-md-2 col-sm-6 col-xs-6 text-center">
308
            {% if request.user == bid.bidder.user and not listing.exchanged and not listing.cancelled %}
Daniel W Bond's avatar
Daniel W Bond committed
309 310
              <h4><a href="{% url 'edit_bid' listing.slug bid.slug %}"<span class="label label-default">Edit</span></a></h4>
            {% endif %}
311 312 313
            {% if bid == listing.winning_bid %}
              <h4><small><span class="label label-success">Winning Bid</span></small> <strong>${{ bid.price }}</strong></h4>
            {% else %}
Daniel W Bond's avatar
Daniel W Bond committed
314
              <h4><strong>${{ bid.price }}</strong></h4>
315
            {% endif %}
Daniel W Bond's avatar
Daniel W Bond committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
            </div>

          </div>

          <hr/>

        <!-- BID DISPLAY -->
        {% endfor %}

        {% if bids %}
        </div>
        {% endif %}

        </div>
      </div>
    </div>
  </div>

</div>

Daniel W Bond's avatar
Daniel W Bond committed
336
{% endblock content %}