detail_listing.html 10.1 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
6
7
8
{% endblock %}

{% block content %}

9
10
{% load crispy_forms_tags %}

11
12
{% load humanize %}

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

Daniel W Bond's avatar
Daniel W Bond committed
16
{% block javascript %}
Daniel W Bond's avatar
Daniel W Bond committed
17
<script type="text/javascript">
Daniel W Bond's avatar
Daniel W Bond committed
18
    $(window).load(function(){
Daniel W Bond's avatar
Daniel W Bond committed
19
20
21
        $('#myModal').modal('show');
    });
</script>
Daniel W Bond's avatar
Daniel W Bond committed
22
{% endblock %}
Daniel W Bond's avatar
Daniel W Bond committed
23
24

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  <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 %}

47
48
49
50
51
52
53
54
55
56
57
58
59
{% if messages %}
  {% for message in messages %}
  <div class="row">
    <div class="col-md-12">
      <div class="alert alert-info alert-dismissable text-center" role="alert">
      <button type="button" class="close" data-dismiss="alert" aria-label="close"><span aria-hidden="true">&times;</span></button>
      <strong>{{ message }}</strong>
      </div>
    </div>
  </div>
  {% endfor %}
{% endif %}

60
{% if listing.cancelled %}
Daniel W Bond's avatar
Daniel W Bond committed
61
62
63
  <div class="row">
    <div class="col-lg-12">
      <div class="alert alert-danger text-center">
64
        <strong>This listing has been cancelled.</strong>
Daniel W Bond's avatar
Daniel W Bond committed
65
66
67
      </div>
    </div>
  </div>
68
{% elif listing.exchanged %}
Daniel W Bond's avatar
Daniel W Bond committed
69
70
  <div class="row">
    <div class="col-lg-12">
71
72
      {% if listing.winning_bid.bidder.user == request.user %}
      <div class="alert alert-success text-center">
73
        <strong>You exchanged this listing {{ listing.date_closed|timesince }} ago.</strong>
74
        {% if rating %}
75
          <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>
76
        {% else %}
77
          <strong>Rate your experience with {{ listing.poster.user.first_name }} <a href="{% url 'create_rating' listing.slug %}">here</a>.</strong>
78
79
        {% endif %}
      {% else %}
Daniel W Bond's avatar
Daniel W Bond committed
80
      <div class="alert alert-danger text-center">
81
        <strong>This listing has been exchanged.</strong>
82
      {% endif %}
Daniel W Bond's avatar
Daniel W Bond committed
83
84
85
      </div>
    </div>
  </div>
86
{% elif not listing.active %}
Daniel W Bond's avatar
Daniel W Bond committed
87
88
  <div class="row">
    <div class="col-lg-12">
89
      <div class="alert alert-warning text-center alert-dismissable">
Daniel W Bond's avatar
Daniel W Bond committed
90
91
        <button type="button" class="close" data-dismiss="alert"
        aria-hidden="true">&times;</button>
92
        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
93
94
95
96
97
      </div>
    </div>
  </div>
{% endif %}

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

115
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
116
  <div class="col-xs-6">
117
118
119
120
121
122
123
    <h4>
      <small>by</small> {{ listing.author }}
      {% if listing.year %}
        ({{ listing.year }})
      {% endif %}
    </h4>
  </div>
Daniel W Bond's avatar
Daniel W Bond committed
124
  <div class="col-xs-6 text-right">
125
126
127
    <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
128

129
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
130
  <div class="col-md-3 col-sm-6 col-xs-6">
131
132
133
      <h4><small>ISBN</small> {{ listing.isbn }}</h4>
  </div>

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

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

Daniel W Bond's avatar
Daniel W Bond committed
149
  <div class="col-md-4 col-sm-6 col-xs-6 text-right">
150
151
    <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 %}
152
153
    (Me)
    {% endif %}</h4>
Daniel W Bond's avatar
Daniel W Bond committed
154
155
156
  </div>
</div>

157
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
158
  <div class="col-md-3 col-sm-6 col-xs-6">
159
160
161
    <h4><small>Condition</small> {{ listing.condition }}</h4>
  </div>

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

Daniel W Bond's avatar
Daniel W Bond committed
166
  <div class="col-md-5 text-right small-text-center">
167
  {% if request.user == listing.poster.user %}
168
169
  {% else %}
    {% if can_flag %}
170
    <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>
171
    {% else %}
172
    <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>
173
174
175
176
177
178
    {% endif %}
  {% endif %}
  </div>
</div>

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

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

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

{% else %}
Daniel W Bond's avatar
Daniel W Bond committed
233
  <div class="col-md-12">
234
235
236
237
238
239
240
    <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">
241
      {% if not listing.cancelled and not listing.exchanged %}
242
243
244
        <div class="row">
          {% crispy my_form %}
        </div>
245
      {% else %}
Daniel W Bond's avatar
Daniel W Bond committed
246
      <div class="col-md-12">
247
248
249
        <h5 class="text-center">This listing has been
          {% if listing.cancelled %}
          cancelled
250
251
          {% elif listing.exchanged %}
          exchanged
252
253
254
          {% endif %}
          and is no longer accepting bids.
        </h5>
255
256
257
258
      </div>
      {% endif %}
      </div>
    </div>
Daniel W Bond's avatar
Daniel W Bond committed
259
260
261
262
  </div>
</div>
{% endif %}

Daniel W Bond's avatar
Daniel W Bond committed
263
<div class="row">
Daniel W Bond's avatar
Daniel W Bond committed
264
  <div class="col-md-12">
Daniel W Bond's avatar
Daniel W Bond committed
265
266
    <div class="panel panel-default" style="margin-top:10px;">
      <div class="panel-heading">
267
        <h4 class="panel-title text-center">
Daniel W Bond's avatar
Daniel W Bond committed
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
          <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
283
            <div class="col-md-3 col-sm-6 col-xs-6 text-center">
284
              <h4><a href="{{ bid.bidder.get_absolute_url }}">
Daniel W Bond's avatar
Daniel W Bond committed
285
286
                {{ bid.bidder.user.first_name }}
                {{ bid.bidder.user.last_name }}
287
              </a></h4>
Daniel W Bond's avatar
Daniel W Bond committed
288
289
            </div>

Daniel W Bond's avatar
Daniel W Bond committed
290
            <div class="col-md-2 col-sm-6 col-xs-6 small-text-center">
291
              <h4><small>{{ bid.created|naturaltime }}</small></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-5 col-sm-6 col-xs-6 small-text-center">
295
              <h4><small>
Daniel W Bond's avatar
Daniel W Bond committed
296
297
298
299
              {% if bid.text %}
                {{ bid.text }}
              {% else %}
              {% endif %}
300
              </small></h4>
Daniel W Bond's avatar
Daniel W Bond committed
301
302
            </div>

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

          </div>

          <hr/>

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

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

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

</div>

{% endblock %}