-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
140 lines (113 loc) · 3.63 KB
/
main.py
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"""State management and initialisation of the application."""
import datetime
from dateutil.relativedelta import relativedelta
import writer
from database import load
from getset import initialise, set_data, set_focus, set_store, set_country, set_district, set_subdistrict, set_category, set_subcategory, set_volume, reset_selection, set_next_page, set_previous_page, set_page_one, set_page
STATE = writer.init_state({
# side
# ----------------------------------------------------------------------------------------------
# Current page of the data.
'side': {
'gjeldende': 1,
'totalt': None,
},
# dropdown
# ----------------------------------------------------------------------------------------------
# Dictionaries containing unique values for the selected category.
# These are used to populate the selection dropdowns.
# Dynamically updated when the category (etc.) is changed.
'dropdown': {
'kategori': {},
'underkategori': {},
'volum': {},
'land': {},
'distrikt': {},
'underdistrikt': {},
'butikk': {},
'passer_til': {},
'argang': {},
'beskrivelse': {},
'kork': {},
'lagring': {},
'full': {
'kategori': [],
'underkategori': [],
'volum': [],
'land': [],
'distrikt': [],
'underdistrikt': [],
'butikk': [],
'passer_til': [],
'argang': [],
'beskrivelse': [],
'kork': [],
'lagring': [],
},
},
# valgt
# ----------------------------------------------------------------------------------------------
# Current selection for each dropdown.
'valgt': {
'kategori': [],
'underkategori': [],
'volum': [],
'land': [],
'distrikt': [],
'underdistrikt': [],
'butikk': [],
'passer_til': [],
'argang': [],
'beskrivelse': [],
'kork': [],
'lagring': [],
'alkohol': None,
'fra': None,
'til': None,
'alkoholfritt': [],
},
# finn
# ----------------------------------------------------------------------------------------------
# Text containing the name to search for.
# Resets when the current selection is changed.
'finn': {
'navn': None,
'filter': False,
},
# data
# ----------------------------------------------------------------------------------------------
# Dictionary containing the discount data for the current selection.
# Dynamically updated when the selection is changed.
# Ordered by the discount percentage.
'data': {
'antall': 10,
'stigende': ['True'],
'fokus': 'prisendring',
'dropdown': {
'prisendring': 'Prisendring',
'literpris': 'Literpris',
'alkoholpris': 'Alkoholpris',
'pris': 'Pris',
'navn': 'Navn',
'volum': 'Volum',
'alkohol': 'Alkohol',
'ny': 'Nyhet',
},
'verdier': None,
},
# flag
# ----------------------------------------------------------------------------------------------
# Flag to indicate when data is being updated, and if the current selection is invalid.
'flag': {
'updating': False,
'invalid': False,
'valid': True,
'butikk': False,
'mellom': True,
'underkategori': False,
'distrikt': False,
'underdistrikt': False,
}
})
initialise(STATE)
STATE.import_stylesheet("style", "static/styles.css")