Skip to content

Commit

Permalink
Merge branch 'next' into temp-file-configuration-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
krestenlaust authored Feb 25, 2024
2 parents 691beb9 + 6f1ecdc commit da8022a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Django==2.2.28
Pillow==8.3.2
Coverage==4.4.1
pytz==2021.3
regex==2017.07.28
freezegun==0.3.15
Django-Select2==5.11.1
django-debug-toolbar==1.11.1
Expand Down
11 changes: 11 additions & 0 deletions stregsystem/management/commands/importmobilepaypayments.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Command(BaseCommand):
# Saves secret tokens to the file "tokens.json" right next to this file.
# Important to use a separate file since the tokens can change and is thus not suitable for django settings.
tokens_file = (Path(__file__).parent / 'tokens.json').as_posix()
tokens_file_backup = (Path(__file__).parent / 'tokens.json.bak').as_posix()
tokens = None

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -55,8 +56,18 @@ def read_token_storage(self):
with open(self.tokens_file, 'r') as json_file:
self.tokens = json.load(json_file)

if self.tokens is None:
self.write_error("read token from storage. 'tokens' is None. Reverting to backup tokens")

with open(self.tokens_file_backup, 'r') as json_file_backup:
self.tokens = json.load(json_file_backup)

# Saves the token variable to disk
def update_token_storage(self):
if self.tokens is None:
self.write_error(f"'tokens' is None. Aborted writing.")
return

with open(self.tokens_file, 'w') as json_file:
json.dump(self.tokens, json_file, indent=2)

Expand Down
4 changes: 2 additions & 2 deletions stregsystem/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import regex
import re


class QuickBuyError(Exception):
Expand All @@ -11,7 +11,7 @@ class QuickBuyParseError(Exception):
pass


_item_matcher = regex.compile(r'(?V1)(?P<productId>\d+)(?::(?P<count>\d+))?$')
_item_matcher = re.compile(r'(?P<productId>\d+)(?::(?P<count>\d+))?$')


def get_token_indexes(string, start_index):
Expand Down
8 changes: 8 additions & 0 deletions stregsystem/static/stregsystem/snow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if(d.getMonth() === 11 && d.getDate() <= 24){
document.body.querySelector(".snow-container").appendChild(santa);

SetBodyChristmasStyle();
InjectChristmasCSS();
}

function SpawnSnowflake () {
Expand All @@ -33,3 +34,10 @@ function SetBodyChristmasStyle() {
bodyStyle.height = "100vh";
bodyStyle.position = "relative"
}

function InjectChristmasCSS(){
let el = document.createElement('style');
el.type = 'text/css';
el.innerText = "a, a:hover, a:active, a:visited { color: white; }";
document.head.appendChild(el);
}
7 changes: 4 additions & 3 deletions stregsystem/templates/stregsystem/purchase_heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ <h2 class="heatmap-header-title">Forbrugsoversigt (Antal)</h2>
.heatmap-label {
position: relative;
padding: .125em .5em .125em 0;
color: black;
fill: black;
font-size: 12.5pt;
}
.heatmap-label-first {
Expand Down Expand Up @@ -101,9 +99,12 @@ <h2 class="heatmap-header-title">Forbrugsoversigt (Antal)</h2>
.heatmap-cell:hover {
border-radius: 5px;
}
.heatmap-mode-button {
font-weight: normal;
}
.heatmap-mode-button[data-active="yes"] {
text-decoration: none;
color: black;
font-weight: bold;
cursor: default;
}

Expand Down
8 changes: 6 additions & 2 deletions stregsystem/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,9 @@ def test_multiple_caffeine_intake_at_odd_times(self):

def test_caffeine_str_is_correct_length(self):
user = Member.objects.create(username="test", gender='F', balance=100)
coffee = Product.objects.create(name="Kaffe☕☕☕", price=1, caffeine_content_mg=CAFFEINE_IN_COFFEE, active=True)
coffee = Product.objects.create(
name="Kaffe☕☕☕", price=1, caffeine_content_mg=CAFFEINE_IN_COFFEE, active=True
)

# do five sales of coffee and assert that emoji renderer returns same amount of emoji
sales = 5
Expand Down Expand Up @@ -1852,7 +1854,9 @@ def test_if_sunday_is_in_week(self):
average_developer = Member.objects.create(username="my-gal", gender="F", balance=50)
coffee_category = Category.objects.create(name="Caffeine☕☕☕", pk=6)
coffee_category.save()
coffee = Product.objects.create(name="Kaffe☕☕☕", price=1, caffeine_content_mg=CAFFEINE_IN_COFFEE, active=True)
coffee = Product.objects.create(
name="Kaffe☕☕☕", price=1, caffeine_content_mg=CAFFEINE_IN_COFFEE, active=True
)
# matches coffee id in production. Will be implemented with categories later, when production have a coffee
# category
coffee.save()
Expand Down

0 comments on commit da8022a

Please sign in to comment.