forked from djbrown/hbscorez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
48 lines (40 loc) · 1.8 KB
/
models.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
from django.conf import settings
from django.db import models
from django.urls import reverse
class Association(models.Model):
name = models.TextField(unique=True)
abbreviation = models.TextField()
bhv_id = models.IntegerField(unique=True)
def __str__(self):
return f'{self.abbreviation} ({self.bhv_id})'
def get_absolute_url(self):
return reverse('associations:detail', kwargs={'bhv_id': self.bhv_id})
@staticmethod
def build_source_url(bhv_id):
return f'{settings.ROOT_SOURCE_URL}Spielbetrieb/index.php?orgGrpID={bhv_id}'
def source_url(self):
return self.build_source_url(self.bhv_id)
@staticmethod
def get_association_abbreviation(association_name: str) -> str | None:
association_abbreviations = {
'Badischer Handball-Verband': 'BHV',
'Fédération Luxembourgeoise de Handball': 'FLH',
'Hamburger Handball-Verband': 'HHV',
'Handball Baden-Württemberg': 'HBW',
'Handball-Verband Saar': 'HVS',
'Handballoberliga Rheinland-Pfalz/Saar': 'RPS',
'Handballverband Rheinhessen': 'HVR',
'Handballverband Schleswig-Holstein': 'HVSH',
'Handballverband Westfalen': 'HVWF',
'Handballverband Württemberg': 'HVW',
'Oberliga Hamburg - Schleswig-Holstein': 'HHSH',
'Pfälzer Handballverband': 'PfHV',
'Südbadischer Handballverband': 'SHV',
'Vorarlberger Handballverband': 'VHV',
# 'Mitteldeutscher Handball-Verband': 'MHV',
# 'Thüringer Handball-Verband': 'THV',
}
for key in association_abbreviations:
if key in association_name:
return association_abbreviations[key]
#return association_abbreviations[association_name]