Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions django/geno/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ContractViewSet(viewsets.ReadOnlyModelViewSet):
# permission_classes = [permissions.IsAuthenticated]


# TODO: This is now done directly in report/nk/contract.py => Remove together with legacy code in report/nk_report.py
class Akonto(APIView):
"""
Get paid akonto amount for contract and billing period.
Expand Down Expand Up @@ -162,6 +163,7 @@ def get_akonto_for_all_contracts(self):
return akonto_total


# TODO: This is now done directly in report/nk/bill.py => Remove together with legacy code in report/nk_report.py
class QRBill(APIView):
"""
Create and return QRBill and execute corresponding accounting transactions.
Expand Down
21 changes: 18 additions & 3 deletions django/geno/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,23 @@
egid = models.PositiveIntegerField("EGID", null=True, blank=True)
active = models.BooleanField("Aktiv", default=True)

@property
def full_name(self):
ret = self.name
if self.street_name and self.house_number:
address = "%s %s" % (self.street_name, self.house_number)
else:
address = self.street_name

Check warning on line 743 in django/geno/models.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 743
if address and address != self.name:
ret += ", %s" % address

Check warning on line 745 in django/geno/models.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 745
if self.city_zipcode and self.city_name:
ret += ", %s %s" % (self.city_zipcode, self.city_name)
elif self.city_name:
ret += ", %s" % self.city_name

Check warning on line 749 in django/geno/models.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on lines 748-749
if self.country and self.country != get_default_country_code():
ret += ", %s" % self.get_country_display()

Check warning on line 751 in django/geno/models.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 751
return ret

class Meta:
ordering = ["name"]
verbose_name = "Liegenschaft"
Expand Down Expand Up @@ -1227,9 +1244,7 @@
name = models.CharField("Nachname", max_length=30)
first_name = models.CharField("Vorname", max_length=30)
email = models.EmailField("Email")
telephone = models.CharField(
"Telefon", max_length=30, blank=True, help_text="Angabe zwingend wegen COVID-19 Massnahmen"
)
telephone = models.CharField("Telefon", max_length=30, blank=True)
slot = models.ForeignKey(
RegistrationSlot, verbose_name="Datum/Zeit Beginn", on_delete=models.CASCADE
)
Expand Down
11 changes: 10 additions & 1 deletion django/geno/tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,16 @@ def create_registrationevents(cls):

def create_buildings(cls, count=2):
cls.buildings = []
for i in range(count):
cls.buildings.append(
Building.objects.create(
name="Musterweg 1",
street_name="Musterweg",
house_number="1",
city_zipcode="3000",
city_name="Bern",
)
)
for i in range(2, count):
cls.buildings.append(Building.objects.create(name=f"Musterweg {i + 1}"))


Expand Down
9 changes: 7 additions & 2 deletions django/geno/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@

def decode_from_iso8859(file):
for line in file:
yield line.decode("iso8859")

Check warning on line 212 in django/geno/utils.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 212


def nformat(number, precision=2):
return format(number, ",.%df" % precision).replace(",", "'")
def nformat(number, precision=2, round_to=False, thousands_separator="'"):
if round_to:
number = round_to * round(number / round_to)
if thousands_separator:
return format(number, ",.%df" % precision).replace(",", thousands_separator)
else:
return format(number, ".%df" % precision)

Check warning on line 221 in django/geno/utils.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 221


def sanitize_filename(filename):
Expand Down
32 changes: 32 additions & 0 deletions django/report/generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import copy


class ReportGenerator:
default_config = {}

def __init__(self, report, *args, **kwargs):
self.config = copy.deepcopy(self.default_config)
self.config.update(report.get_report_config())

self._warnings = {}

def add_warning(self, text, obj):
obj_str = str(obj)
if text in self._warnings:
if obj_str not in self._warnings[text]:
self._warnings[text].append(obj_str)
else:
self._warnings[text] = [obj_str]

def get_warnings(self, space_lines_longer_than=249):
lines = []
for warning, objects in self._warnings.items():
line = f"{warning}: {', '.join(objects)}"
if space_lines_longer_than and len(line) > space_lines_longer_than:
lines.extend(["", line, ""])

Check warning on line 26 in django/report/generator.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 26
else:
lines.append(line)
return lines

def generate(self):
raise NotImplementedError()

Check warning on line 32 in django/report/generator.py

View workflow job for this annotation

GitHub Actions / test

Missing coverage

Missing coverage on line 32
Empty file added django/report/nk/__init__.py
Empty file.
Loading
Loading