Exemple #1
0
def event_active(request, event_id):
    event = get_object_or_404(Event, id = event_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                event.active = True
                message = "Event has been made active."
                messages.add_message(request, messages.INFO, message)
            elif confirm == "no":
                event.active = False
                message = "Event has been made inactive."
                messages.add_message(request, messages.INFO, message)
            event.save()
            return redirect("events_admin")
        return render(request,
                  "trwibc_app/event_active.html",
                  {"event": event,
                   "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/event_active.html",
                  {"event": event,
                   "form": form,})
Exemple #2
0
def image_delete(request, image_id):
    image = get_object_or_404(MyImage, id = image_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            if form.cleaned_data["confirm"] == "yes":
                image.delete()
                message = "Image deleted."
                messages.add_message(request, messages.INFO, message)
            return redirect("images")
        return render(request,
                      "trwibc_app/image_delete.html",
                      {"image": image,
                       "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/image_delete.html",
                  {"image": image,
                  "form": form,})
Exemple #3
0
def users_admin_delete(request, member_id):
    member = get_object_or_404(MyUser, id = member_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes": #prevent deletion of self
                message = member.first_name + " " + member.last_name + " has been deleted."
                messages.add_message(request, messages.INFO, message)
                member.delete()
            return redirect("users_admin")
        return render(request,
                  "trwibc_app/reject.html",
                  {"member": member,
                   "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/reject.html",
                  {"member": member,
                   "form": form,})
Exemple #4
0
def event_delete(request, event_id):
    event = get_object_or_404(Event, id = event_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                event.delete()
                message = "Event deleted."
                messages.add_message(request, messages.INFO, message)
            return redirect("events_admin")
        return render(request,
                  "trwibc_app/event_delete.html",
                  {"event": event,
                   "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/event_delete.html",
                  {"event": event,
                   "form": form,})
Exemple #5
0
def announcement_delete(request, announcement_id):
    announcement = get_object_or_404(Announcement, id = announcement_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                message = "Announcement from " + announcement.member.first_name + " " + announcement.member.last_name + " has been deleted."
                messages.add_message(request, messages.INFO, message)
                announcement.delete()
            return redirect("announcement_admin")
        return render(request,
                      "trwibc_app/announcement_delete.html",
                      {"announcement": announcement,
                       "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/announcement_delete.html",
                  {"announcement": announcement,
                   "form": form,})
Exemple #6
0
def affiliate_delete(request, affiliate_id):
    affiliate = get_object_or_404(Affiliate, id = affiliate_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                message = "Affiliate '" + affiliate.name + "' has been deleted."
                messages.add_message(request, messages.INFO, message)
                affiliate.delete()
            return redirect("affiliates_admin")
        return render(request,
                      "trwibc_app/affiliate_delete.html",
                      {"affiliate": affiliate,
                       "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/affiliate_delete.html",
                  {"affiliate": affiliate,
                   "form": form,})
Exemple #7
0
def announcement_active(request, announcement_id):
    announcement = get_object_or_404(Announcement, id = announcement_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                announcement.active = True
            elif confirm == "no":
                announcement.active = False
            announcement.save()
            return redirect("announcement_admin")
        return render(request,
                      "trwibc_app/announcement_active.html",
                      {"announcement": announcement,
                       "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/announcement_active.html",
                  {"announcement": announcement,
                   "form": form,})
Exemple #8
0
def announcements_my_delete(request, announcement_id):
    if request.user != get_object_or_404(Announcement, id = announcement_id).member:
        raise Http404
    announcement = get_object_or_404(Announcement, id = announcement_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            if form.cleaned_data["confirm"] == "yes":
                announcement.delete()
                message = "Announcement has been deleted."
                messages.add_message(request, messages.INFO, message)
            return redirect("announcements_my")
        return render(request,
                      "trwibc_app/announcements_my_delete.html",
                      {"announcement": announcement,
                       "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/announcements_my_delete.html",
                  {"announcement": announcement,
                   "form": form,})
Exemple #9
0
def users_admin_make_admin(request, member_id):
    member = get_object_or_404(MyUser, id=member_id)
    if request.method == "POST":
        form = YesNoForm(request.POST)
        if form.is_valid():
            confirm = form.cleaned_data["confirm"]
            if confirm == "yes":
                member.is_admin = True
                message = member.first_name + " " + member.last_name + " has been made an administrator."
            elif confirm == "no": #add condition to check that user is not me/Debbie
                member.is_admin = False
                message = member.first_name + " " + member.last_name + " has lost admin priveleges."
            messages.add_message(request, messages.INFO, message)
            member.save()
            return redirect("users_admin")
        return render(request,
                  "trwibc_app/users_admin_make_admin.html",
                  {"member": member,
                   "form": form,})
    form = YesNoForm()
    return render(request,
                  "trwibc_app/users_admin_make_admin.html",
                  {"member": member,
                   "form": form,})