Fixed band parsing in cbrparser

This commit is contained in:
Sebastian Lohff 2017-02-05 13:31:26 +01:00 committed by root
parent a79269c65d
commit 9db317e625
2 changed files with 9 additions and 2 deletions

View File

@ -50,10 +50,17 @@ def parseCBR(raw):
qm = qsore.search(q) qm = qsore.search(q)
if qm: if qm:
qsoData = qm.groupdict() qsoData = qm.groupdict()
qsoData["band"] = "2m" if qsoData["band"] == 144 else "70cm"
qsoTime = timezone.datetime.strptime(qsoData["datetime"], "%Y-%m-%d %H%M") qsoTime = timezone.datetime.strptime(qsoData["datetime"], "%Y-%m-%d %H%M")
qsoData["datetime"] = timezone.get_current_timezone().localize(qsoTime) qsoData["datetime"] = timezone.get_current_timezone().localize(qsoTime)
qsoData["no_s"] = qsoNo qsoData["no_s"] = qsoNo
if qsoData["band"] == "144":
qsoData["band"] = "2m"
elif qsoData["band"] == "432":
qsoData["band"] = "70cm"
else:
raise forms.ValidationError("Error parsing band, needs to be either 144 or 432 (as we only support 2m and 70cm in this contest")
info["qsos"].append(qsoData) info["qsos"].append(qsoData)
if info["call"] != qsoData["call_s"]: if info["call"] != qsoData["call_s"]:

View File

@ -220,4 +220,4 @@ class QSO(models.Model):
super(QSO, self).save(*args, **kwargs) super(QSO, self).save(*args, **kwargs)
def __str__(self): def __str__(self):
return "QSO no %s at from %s %s with %s@%s %s/%s" % (self.ownNo, self.time.strftime("%H:%M"), self.owner.username, self.call, self.refStr, self.reportTX, self.reportRX) return "QSO no %s at %s on band %s from %s with %s@%s %s/%s" % (self.ownNo, self.time.strftime("%H:%M"), self.band, self.owner.username, self.call, self.refStr, self.reportTX, self.reportRX)