forked from Scouterna/skojjt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dakdata.py
86 lines (68 loc) · 2.69 KB
/
dakdata.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
# -*- coding: utf-8 -*-
"""
Module for exporting data according to DAC format.
http://www.sverigesforeningssystem.se/dak-formatet/vad-ar-dak/
"""
import datetime
class Deltagare(object):
def __init__(self, uid, foernamn, efternamn, personnummer, ledare, epost="", mobil_nr="", postnummer=""):
self.uid = uid
self.foernamn = foernamn
self.efternamn = efternamn
self.personnummer = personnummer
self.ledare = ledare
self.epost = epost
self.mobil_nr = mobil_nr
self.postnummer = postnummer
def is_female(self):
"Return True if the person is female"
return False if int(self.personnummer[-2])&1 == 1 else True
def age_this_semester(self, semester):
"Is the person aget this semester"
return int(self.personnummer[0:4]) - semester.year
def __eq__(self, other):
return self.personnummer == other.personnummer
def __hash__(self):
return hash(self.personnummer)
class Sammankomst(object):
def __init__(self, kod, datum, duration, aktivitet):
self.kod = kod
self.datum = datum
self.duration = duration
self.aktivitet = aktivitet # OBS en av: Traening, Match, Moete, Oevrigt
self.deltagare = []
self.ledare = []
def get_date_string(self, format_string='%Y-%m-%d'):
return self.datum.strftime(format_string)
def get_start_time_string(self, format_string='%H:%M:%S'):
return self.datum.strftime(format_string)
def get_stop_time_string(self, format_string='%H:%M:%S'):
max_end_time = self.datum.replace(hour=23, minute=59, second=59)
endtime = self.datum + datetime.timedelta(minutes=self.duration)
if endtime > max_end_time:
endtime = max_end_time # limit to the current day (to keep Stop time after Start time)
return endtime.strftime(format_string)
def get_all_persons(self):
return self.ledare + self.deltagare
def is_person_attending(self, person):
for person in self.get_all_persons():
if person.Personnummer == person.Personnummer:
return person.Attending
return False
class Narvarokort(object):
def __init__(self):
self.deltagare = []
self.ledare = []
self.sammankomster = []
self.naervarokort_nummer = ""
self.lokal = "Scouthuset"
self.namn_paa_kort = ""
self.aktivitet = "" # OBS en av: Traening, Match, Moete, Oevrigt
class DakData(object):
"Main container for DAK data"
def __init__(self):
self.kort = Narvarokort()
self.kommun_id = ""
self.forenings_id = ""
self.foerenings_namn = ""
self.organisationsnummer = ""