Beispiel #1
0
def global_notifications(request):
    try:
        notifications_obj = Notifications.objects.get(user=None)
    except:
        notifications_obj = Notifications(user=None)

    form = NotificationsForm(instance=notifications_obj)
    if request.method == 'POST':
        form = NotificationsForm(request.POST, instance=notifications_obj)
        if form.is_valid():
            new_settings = form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Settings saved.',
                                 extra_tags='alert-success')

    add_breadcrumb(title="Global notification settings", top_level=False, request=request)
    return render(request, 'dojo/notifications.html',
                  {'form': form,
                   'scope': 'global',
                   'admin': request.user.is_superuser})
Beispiel #2
0
def system_notifications(request):
    try:
        notifications_obj = Notifications.objects.get(user=None,
                                                      product__isnull=True)
    except:
        notifications_obj = Notifications(user=None)

    form = NotificationsForm(instance=notifications_obj)
    if request.method == 'POST':
        form = NotificationsForm(request.POST, instance=notifications_obj)
        if form.is_valid():
            new_settings = form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Settings saved.',
                                 extra_tags='alert-success')

    add_breadcrumb(title="System notification settings",
                   top_level=False,
                   request=request)
    return render(
        request, 'dojo/notifications.html', {
            'form': form,
            'scope': 'system',
            'enabled_notifications': get_enabled_notifications_list(),
            'admin': request.user.is_superuser
        })
Beispiel #3
0
def personal_notifications(request):
    try:
        notifications_obj = Notifications.objects.get(user=request.user)
    except:
        notifications_obj = Notifications(user=request.user)

    form = NotificationsForm(instance=notifications_obj)
    if request.method == 'POST':
        form = NotificationsForm(request.POST, instance=notifications_obj)
        if form.is_valid():
            new_settings = form.save()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Settings saved.',
                                 extra_tags='alert-success')

    add_breadcrumb(title="Personal notification settings",
                   top_level=False,
                   request=request)
    return render(request, 'dojo/notifications.html', {
        'form': form,
        'scope': 'personal',
        'admin': request.user.is_superuser
    })