Beispiel #1
0
    def write_clients(self, csv_dict):
        for name, values in csv_dict.items():
            print(name)
            try:
                o = Orte.objects.get(ort=values['Ort'].strip())
            except:
                print('{} hat keinen bekannten Ortsnamen: {}'.format(
                    name, values['Ort']))
                exit()
            print(o)
            # Strasse und Hausnr aufsplitten
            z = re.match("(.+)\s(\d+-*\d*)$", values['Strasse'])
            [strasse, hausnr] = z.groups()
            try:
                s = Strassen.objects.get(ort=o, strasse=strasse.strip())
            except:
                print('{} hat keinen bekannten Strassennamen: {}'.format(
                    name, strasse))
                exit()
            print(s)

            instance = Klienten(name=name,
                                ort=o,
                                strasse=s,
                                hausnr=hausnr,
                                kategorie=values['Kategorie'],
                                bemerkung=values['Sparte'],
                                dsgvo='99',
                                typ="D",
                                telefon='-'.join(
                                    [values['Vorwahl'], values['Tel.Nr.']]))
            GeoLocation().getLocation(instance)
            instance.save()
Beispiel #2
0
 def save(self, *args, **kwargs):
     if self.ort.bus != None and self.typ == 'F':
         self.bus = self.ort.bus
     if self.typ in ['D', 'S']:
         self.dsgvo = '99'
     if self.latitude == 0:
         GeoLocation().getLocation(self)
     if not settings.ALLOW_OUTSIDE_CLIENTS \
             and not self.ort.bus \
             and self.typ == 'F':
         raise ValidationError("Fahrgäste aus diesem Ort sind nicht erlaubt")
     super(Klienten, self).save(*args, **kwargs)
 def form_valid(self, form):
     instance = form.save(commit=False)
     instance.updated_by = self.request.user
     if instance.latitude == 0 or set(
         ['ort', 'strasse', 'hausnr']).intersection(set(form.changed_data)):
         GeoLocation().getLocation(instance)
     instance.save(force_update=True)
     self.success_message = 'Dienstleister "<a href="' + self.success_url + str(
         instance.id
     ) + '">' + instance.name + '</a>" wurde erfolgreich geändert.'
     self.success_url += url_args(self.request)
     return super(DienstleisterChangeView, self).form_valid(form)
Beispiel #4
0
 def form_valid(self, form):
     instance = form.save(commit=False)
     if instance.latitude == 0 or set(
         ['ort', 'strasse', 'hausnr']).intersection(set(form.changed_data)):
         GeoLocation().getLocation(instance)
     instance.created_by = self.request.user
     instance.save()
     self.success_message = 'Bus Standort "<a href="' + self.success_url + str(
         instance.id) + '/' + url_args(
             self.request
         ) + '">' + instance.name + '</a>" wurde erfolgreich hinzugefügt.'
     self.success_url += url_args(self.request)
     return super(StandortAddView, self).form_valid(form)