aboutsummaryrefslogtreecommitdiff
path: root/templates/beerpage.jinja2
blob: 68291afa69d5927c73a8ee1c355fe2898fb14539 (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
{% extends "base.html" %}
{% block content %}

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script>
    google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawAnnotations);

function drawAnnotations() {
      var data = new google.visualization.DataTable();
      data.addColumn('timeofday', 'Time of Day');
      data.addColumn('number', 'Motivation Level');
      data.addColumn({type: 'string', role: 'annotation'});
      data.addColumn('number', 'Energy Level');
      data.addColumn({type: 'string', role: 'annotation'});

      data.addRows([
        [{v: [8, 0, 0], f: '8 am'},   1, '1',  .25, '.2'],
        [{v: [9, 0, 0], f: '9 am'},   2, '2',   .5, '.5'],
        [{v: [10, 0, 0], f:'10 am'},  3, '3',    1,  '1'],
        [{v: [11, 0, 0], f: '11 am'}, 4, '4', 2.25,  '2'],
        [{v: [12, 0, 0], f: '12 pm'}, 5, '5', 2.25,  '2'],
        [{v: [13, 0, 0], f: '1 pm'},  6, '6',    3,  '3'],
        [{v: [14, 0, 0], f: '2 pm'},  7, '7', 3.25,  '3'],
        [{v: [15, 0, 0], f: '3 pm'},  8, '8',    5,  '5'],
        [{v: [16, 0, 0], f: '4 pm'},  9, '9',  6.5,  '6'],
        [{v: [17, 0, 0], f: '5 pm'}, 10, '10',  10, '10'],
      ]);

      var options = {
        title: 'Motivation and Energy Level Throughout the Day',
        annotations: {
          alwaysOutside: true,
          textStyle: {
            fontSize: 14,
            color: '#000',
            auraColor: 'none'
          }
        },
        hAxis: {
          title: 'Time of Day',
          format: 'h:mm a',
          viewWindow: {
            min: [7, 30, 0],
            max: [17, 30, 0]
          }
        },
        vAxis: {
          title: 'Rating (scale of 1-10)'
        }
      };

      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
    <div id="title" class="text-center">
        <h2>{{ beer_data.brewer if beer_data != None else 'DELICOUS BREWER' }}</h2>
        <h2>{{ beer_data.name if beer_data != None else 'DELICOUS BEER' }}</h2>
    </div>
    <div id="stats">
        <table class="table">
            <tr>
                <th scope="col">Parent Style</th>
                <th scope="col">Specific Style</th>
                <th scope="col">Alcohol by Volume </th>
            </tr>
            <tr>
                <td>{{ beer_data.parent_style if beer_data != None else 'ASS BEER' }}</td>
                <td>{{ beer_data.base_style if beer_data != None else 'TURBO ASS BEER' }}</td>
                <td>{{ beer_data.abv if beer_data != None else 'BETWEEN 0 and 100' }} (drinks like: {{beer_data.drinks_like|round(2)}})</td>
            </tr>
        </table>
    </div>
    <div id="chart_div"></div>
    <h5>Beers like {{ beer_data.name }}</h5>
    <ul>
      {% for similar_beer in similar_beers %}
          <li><a href="{{ similar_beer.link }}" >{{ similar_beer.name }}</a></li>
      {% endfor %}
    </ul>

    <form action="" method="post" class="form-inline alert alert-secondary">
      Show me beers which are
      <select name="direction" class="form-control">
          <option {% if direction == '3' %}selected{% endif %} value="3">Much more</option>
          <option {% if direction == '2' %}selected{% endif %} value="2">More</option>
          <option {% if direction == '1' %}selected{% endif %} value="1">Little more</option>
          <option {% if direction == '-1' %}selected{% endif %} value="-1">Little less</option>
          <option {% if direction == '-2' %}selected{% endif %} value="-2">Less</option>
          <option {% if direction == '-3' %}selected{% endif %} value="-3">Much less</option>
      </select>
      <select name="attr" class="form-control">
        {% for a in attrs %}
          <option {% if a == attr %}selected{% endif %} value="{{ a }}">{{ a }}</option>
        {% endfor %}
      </select>
      <input type="submit" value="Go" class="btn btn-outline-primary">
    </form>

    {% if attr_beers %}
    <h5>Beers like {{ beer_data.name }} but {{ direction }} {{ attr }}</h5>
    <ul>
      {% for attr_beer in attr_beers %}
      <li><a href="{{ attr_beer.link }}" >{{ attr_beer.name }}</a></li>
      {% endfor %}
    </ul>
    {% endif %}

{% endblock %}