summaryrefslogtreecommitdiffstats
path: root/bitvend/templates/index.html
blob: e66f9a4aa206175fde2461e30ada743b955f7f2a (plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
{% extends "base.html" %}

{% from "_formathelpers.html" import format_currency %}
{% from "_formhelpers.html" import render_field, render_submit %}

{% block content %}
  {% if not mdb_online or not proc_online %}
  <div class="alert alert-warning">
      <b>Some of the subsystems are misbehaving.</b> Please avoid making payments, unless in absolute need of Mate.
  </div>
  {% endif %}

  {% if current_user.is_authenticated %}
  <div class="row">
      <div class="col-sm-4">
          <div class="well text-right">
              <h3><small class="pull-left">Balance</small> <small>{{ format_currency(current_user.amount_available) }} / </small> {{ format_currency(current_user.balance) }}</h3>
          </div>

          <div class="well text-right">
              <h3><small class="pull-left">Transactions</small> {{ current_user.transactions.count() }}</h3>
          </div>

          <div class="well">
          {% if current_transaction %}
              <a href="{{ url_for('.cancel') }}" class="btn btn-danger btn-block btn-lg">Cancel transaction
                  {% if current_transaction.user != current_user %}
                      <small>(by {{ current_transaction.user }})</small>
                  {% endif %}
              </a>
          {% else %}
              <a href="{{ url_for('.begin') }}" class="btn btn-primary btn-block btn-lg">Begin transaction</a>
          {% endif %}
          </div>

          <form action="{{ url_for('.transfer') }}" method="POST" class="well">
              {{ transfer_form.hidden_tag() }}
              <div class="form-group">
                  <input type="input" class="form-control" name="target" placeholder="target username" />
              </div>
              <div class="form-group">
              <div class="input-group">
                  <input type="number" class="form-control" min="0" name="amount" placeholder="0.00" step="any" />
                  <span class="input-group-btn">
                      <button class="btn btn-info">Transfer</button>
                  </span>
              </div>
              </div>
          </form>
      </div>
      <div class="col-sm-8">
          <h3 class="page-header">Latest transactions</h3>
          <table class="table table-hover table-striped">
              <thead>
                  <tr>
                      <th>Type</th>
                      <th>Amount</th>
                      <th>Date</th>
                  </tr>
              </thead>

              {% for tx in transactions %}
                  <tr{% if not tx.finished %} style="opacity: 0.5"{% endif %}>
                      <td>
                          {{ tx.type }} {% if not tx.finished %}<i>(processing)</i>{% endif %}
                          <small>
                          {% if tx.type == 'transfer' and tx.amount > 0 %}
                              from <b>{{ tx.related_user }}</b>
                          {% elif tx.type == 'transfer' and tx.amount < 0 %}
                              to <b>{{ tx.related }}</b>
                          {% elif tx.type == 'purchase' and tx.product_id %}
                              of product <b>{{ tx.product_id }}</b>
                          {% endif %}
                          </small>
                      </td>
                      <td>{{ format_currency(tx.amount) }}</td>
                      <td>{{ tx.created }}</td>
                  </tr>
              {% else %}
                  <tr><td colspan=3 class="placeholder">Nothing to see here...</td></tr>
              {% endfor %}
          </table>
      </div>
  </div>
  <hr>
  {% endif %}

  <div class="alert alert-info">
      This is just a test deployment of Warsaw Hackerspace Vending Machine Bitcoin Payments System™.<br />
      <b>Please report any issues to <a href="mailto:informatic@hackerspace.pl" class="alert-link">informatic@hackerspace.pl</a>.</b>
  </div>

  <div class="row">
  {% for item in items %}
  <div class="col-md-6">
      <div class="well vend-item">
          <div class="row">
              <div class="col-md-12">
                  <div class="pull-right">
                      <span class="label label-info">{{ format_currency(item.value) }}</span>
                      <span class="label label-primary">{{ format_btc(from_local_currency(item.value*1.03)) }}</span>
                  </div>
                  <h3>{{ item.name }}</h3>
              </div>
              <div class="col-xs-6">
                  <img src="{{ item.image }}"  class="img-responsive center-block" />
              </div>
              <div class="col-xs-6 text-center">
                  {% with btc_uri = 'bitcoin:%s?amount=%s' % (config['INPUT_ADDRESS'], sat_to_btc(from_local_currency(item.value*1.03))) %}
                  <a href="{{ btc_uri }}">
                      <img src="{{ qrcode(btc_uri) }}" class="img-responsive center-block"/>
                      <code><small>{{ config['INPUT_ADDRESS'] }}</small></code>
                  </a>
                  {% endwith %}
              </div>
          </div>
      </div>
  </div>
  {% endfor %}
  </div>
{% endblock %}