profile.html 8.9 KB
Newer Older
1
2
3
4
{% extends 'layouts/base.html' %}
{% load website_extras %}

{% block title %}
5
SRCT Bookshare • Seller Profile
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
{% endblock %}

{% block content %}

<script>
function insert_target( source, target ){
  var element = document.getElementById( source );
  element.setAttribute("value", target);
}
</script>

<div class="page-header" id="banner">
  <div class="row">
    <div class="col-lg-12">
      <h1>{{ seller.user.first_name }} {{ seller.user.last_name }}
      {% if seller.user = request.user %}
      (me)
      {% endif %}
      <span class="pull-right">
        <a href="mailto:{{ seller.user.email }}">{ contact }</a>
      </span></h1>
      <p class="lead">
        {% if seller.rating %}
          <span class="glyphicon glyphicon-star"></span>
          <span class="glyphicon glyphicon-star"></span>
          <span class="glyphicon glyphicon-star"></span>
          <span class="glyphicon glyphicon-star-empty"></span>
          <span class="glyphicon glyphicon-star-empty"></span>
        {% else %}
          No ratings yet.
        {% endif %}
      </p>
    </div>
  </div>
</div>

<div class="row">

  <div class="col-md-12">
    {% if seller == request.user.seller %}
    <h3>Listings (<a href="{%url 'create_listing'%}">Create</a>)</h3>
    {% else %}
    <h3>Listings</h3>
    {% endif %}

    {% if listings %}

      <div class="table-responsive">
        <table class="table table-bordered">

          <thead>
            <th class="col-md-1 text-center">ISBN</th>
            <th class="col-md-9">Title</th>
            <th class="col-md-1 text-center">Price</th>
            <th class="col-md-1 text-center">
              {% if seller.user = request.user %}
              Action
              {% else %}
              Status
              {% endif %}
            </th>
          </thead>

          {% for listing in listings %}
            <tr>
              <td class="text-center">{{ listing.ISBN }}</td>

              <td>
                {% if listing.active %}
                  <a href="{{ listing.get_absolute_url }}">{{ listing.title }}</a>
                  {% else %}
                  {{ listing.title }}
                {% endif %}
              </td>

              <td class="text-center">
                {% if listing.sold %}
                  ${{ listing.finalPrice }}
                {% elif not listing.active %}
                  $0
                {% else %}
                  ${{ listing.price }}
                {% endif %}
              </td>

              <td class="text-center">
                {% if listing.sold %}
                  <span class="label label-danger">Sold</span>
                {% elif not listing.active %}
                  <span class="label label-default">Closed</span>
                {% else %}
                  {% if seller.user = request.user %}
                    <a href="#" onclick="insert_target('{{close_form.book_id.id_for_label}}', '{{ listing.pk }}');"
                    data-toggle="modal" data-target="#CloseConfirm">Close</a> / 
                    <a href="#" onclick="insert_target('{{FinalPrice_form.book_id.id_for_label}}', '{{ listing.pk }}');"
                    data-toggle="modal" data-target="#FinalPrice">Sold</a>
                  {% else %}
                    <span class="label label-success">Unsold</span>
                  {% endif %}
                {% endif %}
              </td>

            </tr>
          {% endfor %}

          {% if seller.user = request.user %}
          <tr>
            <td class="text-center">-</td>
            <td class="text-right"><strong>Total Proceeds:</strong></td>
            <td class="text-center">${{ total_sold }}</td>
            <td class="text-center">-</td>
          </tr>
          {% endif %}

        </table>
      </div>

    {% else %}
      {% if seller.user = request.user %}
      You don't
      {% else %}
      {{ seller.user.first_name }} {{ seller.user.last_name }} doesn't 
      {% endif %}
      have any listings posted yet.
    {% endif %}
  </div>
</div>

{% if seller.user = request.user %}

<hr/>

<div class="row">
  <div class="col-md-12">
    <h3>Your Lookouts (<a data-toggle="modal" data-target="#CreateLookout"
    href="#">Create</a>)</h3>
    {% if lookouts %}

      <div class="table-responsive">
        <table class="table table-bordered">

          <thead>
            <th class="col-md-1 text-center">ISBN</th>
            <th class="col-md-10">Title</th>
            <th class="col-md-1 text-center">Action</th>
          </thead>

          {% for lookout in lookouts %}
          <tr>
            <td class="text-center">{{lookout.ISBN}}</td>
            <td>{{lookout.ISBN|get_isbn_data:"title"}}</td>
            <td class="text-center">
              <a href="#" onclick="insert_target('{{DeleteLookout_form.lookout_id.id_for_label}}', '{{ lookout.pk }}');"
              data-toggle="modal" data-target="#DeleteLookout">Delete</a>
            </td>
          </tr>
          {% endfor %}

        </table>
      </div>
    {% else %}
      You don't have any lookouts set yet.
    {% endif %}
  </div>
</div>
{% endif %}


<!-- Final Price Modal -->
<div class="modal fade" id="FinalPrice" tabindex="-1" role="dialog"
aria-labelledby="FinalPriceLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <form class="form-horizontal" id="FinalPriceForm" method="post"
      action="" role="form">
        {%csrf_token%}
        {{FinalPrice_form.book_id}}

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
          aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="FinalPriceLabel">Final Selling Price</h4>
        </div>

        <div class="modal-body">
          <div class="form-group{%if FinalPrice_form.final_price.errors%} has-error{%endif%}">
            <label class="col-lg-3 control-label" for="{{FinalPrice_form.final_price.id_for_label}}">
              {{FinalPrice_form.final_price.label}}
            </label>
            <div class="col-lg-9">
              <div class="input-group">
                <span class="input-group-addon"> $ </span>
                {{FinalPrice_form.final_price}}
              </div>
            </div>
            <span class="help-block col-lg-9 col-lg-offset-3">
              Enter the final price you sold your book for (optional).
            </span>
          </div>
        </div>

        <div class="modal-footer">
          <a class="btn btn-default btn-sm" data-dismiss="modal">Close</a>
          <input type="submit" class="btn btn-primary btn-sm"
          value="Mark as Sold" name="sold" />
        </div>
      </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- Close Confirm Modal -->
<div class="modal fade" id="CloseConfirm" tabindex="-1" role="dialog"
aria-labelledby="CloseConfirmLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <form class="form-horizontal" id="CloseConfirmForm" method="post"
      action="" role="form">
        {%csrf_token%}
        {{ close_form.book_id }}
        

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
          aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="CloseConfirmLabel">Confirm Listing Closure</h4>
        </div>

        <div class="modal-body text-center">
          Are you sure? This action cannot be undone!
        </div>

        <div class="modal-footer">
          <button class="btn btn-default btn-sm" data-dismiss="modal">
            Cancel
          </button>
          <input type="submit" class="btn btn-primary btn-sm"
          value="Close Listing" name="closed" />
        </div>

      </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- Delete Lookout Modal -->
<div class="modal fade" id="DeleteLookout" tabindex="-1" role="dialog"
aria-labelledby="DeleteLookoutLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <form class="form-horizontal" id="DeleteLookoutForm" method="post"
      action="" role="form">
        {%csrf_token%}
        {{ DeleteLookout_form.lookout_id }}

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"
          aria-hidden="true">&times;</button>
          <h4 class="modal-title" id="DeleteLookoutLabel">Confirm Lookout Deletion</h4>
        </div>

        <div class="modal-body text-center">
          Are you sure? This action cannot be undone!
        </div>

        <div class="modal-footer">
          <button class="btn btn-default btn-sm" data-dismiss="modal">
            Cancel
          </button>
          <input type="submit" class="btn btn-primary btn-sm"
          value="Delete Lookout" name="lookout" />
        </div>

      </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

{% include 'create_lookout_modal.html' %}

{% endblock %}