Exemple #1
0
def invoices(request):
    """ zeigt die Seite mit den Rechnungen aus EdiHub fuer den Kunden an """
    # zuerst ziehen wir eine Rechnungsliste vom EdiHub
    hub = EdiHub(request.customer.kundennr,
                 request.customer.mail)
    invoices = hub.invoices()

    # (Pseudo-)Paginator erzeugen und die Seite anzeigen
    paginator = Paginator(request, 10, len(invoices))
    return render_to_response('beliza/customers/invoices.html',
                              {'invoices': invoices[paginator.start():paginator.stop()],
                               'paginator': paginator},
                              context_instance=RequestContext(request))
Exemple #2
0
def users(request):
    # Check if given user is admin for customer
    def add_user(data):
        """Function for adding a user to the customer"""
        username = data.get('email')
        defaults = {'email': username,
                    'first_name': data.get('firstname'),
                    'last_name': data.get('lastname') }
        user, created = User.objects.get_or_create(username=username, defaults=defaults)
        if created:
            request.customer.users.add(user)
            return render_to_json({'result': 'ok'})
        else:
            return render_to_json({'result': 'error', 'msg': 'Fehler beim Speichern des Benutzers!'})

    def delete_users(raw_ids):
        """Function for removing a list of user_ids"""
        ids = map(lambda id: int(id), raw_ids)
        result = request.customer.users.filter(id__in=ids).delete();
        return render_to_json({'result': 'ok'})

    # sollen wir eine Aktion durchfuehren?
    if request.method == "POST":
        what = request.POST.get('what')
        if what == 'create':
            return add_user(request.POST)
        elif what == 'delete':
            return delete_users(request.POST.getlist('ids[]'))
        else:
            return render_to_json({'result': 'error', 'msg': 'Ungueltige Aktion!'})

    # oder nur die Seite anzeigen?
    row_count = request.customer.users.count()
    paginator = Paginator(request, 10, row_count)
    return render_to_response('beliza/customers/users.html',
                              {'users': request.customer.users.all()[paginator.start():paginator.stop()],
                               'paginator': paginator},
                              context_instance=RequestContext(request))
Exemple #3
0
        elif what == 'delete':
            return delete_notifications(request.POST.getlist('ids[]'))
        else:
            return render_to_json({'result': 'error', 'msg': 'Ungueltige Aktion!'})

    # oder nur die Seite anzeigen?
    api = CreateApiResource('robotRock/Notification')
    notifications = []
    for notification in api.read(request.customer.kundennr):
        notifications.append({'designator': notification.designator,
                              'email': notification.recipient,
                              'event': NOTIFICATION_EVENTS.get(notification.status, '(Unbekanntes Ereignis)')})

    paginator = Paginator(request, 10, len(notifications))
    return render_to_response('beliza/customers/notifications.html',
                              {'notifications': notifications[paginator.start():paginator.stop()],
                               'paginator': paginator},
                              context_instance=RequestContext(request))


@breadcrumb(u'Benutzerverwaltung')
def users(request):
    # Check if given user is admin for customer
    def add_user(data):
        """Function for adding a user to the customer"""
        username = data.get('email')
        defaults = {'email': username,
                    'first_name': data.get('firstname'),
                    'last_name': data.get('lastname') }
        user, created = User.objects.get_or_create(username=username, defaults=defaults)
        if created: