django.http.HttpResponseRedirect - python examples

Here are the examples of the python api django.http.HttpResponseRedirect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new_entry(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    journal_entry = JournalEntry(board=board, author=member)

    if request.method == "POST":
        form = NewJournalEntryForm(request.POST, instance=journal_entry)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:journal:view", args=(board_id,)))
    else:
        form = NewJournalEntryForm(instance=journal_entry)

    return render(request, "journal/entries/new.html", {"form": form, "board": board, "member": member})

3 View Complete Implementation : subscribe.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
def subscribe(request):
    form = SubscribeForm(request.POST or None)
    if form.is_valid():
        form.save()

        logger.info("newsletter subscribe", extra={
            'email': form.instance.email,
            'withevent': False,
        })

        return HttpResponseRedirect(reverse('news:subscribe_done'))

    context = {'form': form}
    return render(request, 'news/subscribe.html', context)

3 View Complete Implementation : auth.py
Copyright MIT License
Author : diegojromerolopez
@transaction.atomic
def trello_signup(request):

    if request.method == "POST":
        form = TrelloSignUpForm(request.POST)

        if form.is_valid():
            member = form.save(commit=True)
            user = authenticate(username=member.user.username, pastword=form.data["pastword1"])
            if user and user is not None:
                django_login(request, user)
                return HttpResponseRedirect(reverse("index"))

    else:
        form = TrelloSignUpForm()

    return render(request, "members/signup/trello_signup.html", {"form": form})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@login_required
def edit(request, hourly_rate_id):
    member = None
    if user_is_member(request.user):
        member = request.user.member

    hourly_rate = HourlyRate.objects.get(id=hourly_rate_id)

    if request.method == "POST":
        form = HourlyRateForm(request.POST, instance=hourly_rate)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("hourly_rates:view_hourly_rates"))

    else:
        form = HourlyRateForm(instance=hourly_rate)

    return render(request, "hourly_rates/edit.html", {"form": form, "member": member, "hourly_rate": hourly_rate})

3 View Complete Implementation : models.py
Copyright MIT License
Author : diegojromerolopez
def new(request, instance, form_clast, template_path, ok_url, extra_form_parameters=None):
    if extra_form_parameters is None:
        extra_form_parameters = {}

    if request.method == "POST":
        form = form_clast(request.POST, request.FILES, instance=instance, **extra_form_parameters)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(ok_url)
    else:
        form = form_clast(instance=instance, **extra_form_parameters)

    replacements = {"form": form, "instance": instance}
    replacements.update(extra_form_parameters)
    return render(request, template_path, replacements)

3 View Complete Implementation : cards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def delete_comment(request, board_id, card_id, comment_id):
    if request.method != "POST":
        raise Http404
    member = request.user.member
    try:
        board = get_user_boards(request.user).get(id=board_id)
        card = board.cards.get(id=card_id)
        comment = card.comments.get(id=comment_id)
    except (Board.DoesNotExist, Card.DoesNotExist, CardComment.DoesNotExist) as e:
        raise Http404

    # Delete the comment
    card.delete_comment(member, comment)
    return HttpResponseRedirect(reverse("boards:view_card", args=(board_id, card_id)))

3 View Complete Implementation : auth.py
Copyright MIT License
Author : diegojromerolopez
def login(request):
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            user = form.cleaned_data["user"]
            django_login(request, user)
            return HttpResponseRedirect(reverse("index"))
    else:
        form = LoginForm()

    return render(request, "members/login.html", {"form": form})

3 View Complete Implementation : admin.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def update_forecaster(request, forecaster_id):
    member = request.user.member
    try:
        forecaster = Forecaster.get_all_from_member(member).get(id=forecaster_id)
    except Forecaster.DoesNotExist:
        raise Http404

    if request.method == "POST":
        form = UpdateForecasterForm(request.POST)
        if form.is_valid():
            form.save(forecaster)
            return HttpResponseRedirect(reverse("forecasters:index"))
    else:
        form = UpdateForecasterForm()

    return render(request, "forecasters/update.html", {"form": form, "forecaster": forecaster, "member": member})

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
@inventory_admin_required
def delete_inventory(request, inventory):
    # permission checking is done in inventory_admin_required
    form = InventoryDeleteForm(request.POST or None, instance=inventory)

    if form.is_valid():
        form.delete()
        return HttpResponseRedirect(reverse('inventory:inventory_list'))

    # render page
    context = {'inventory': inventory,
               'form': form}
    return render(request, 'inventory/admin/delete_inventory.html', context)

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def unarchive(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    # Show un-archive form
    if request.method == "GET":
        replacements = {"member": member, "board": board}
        return render(request, "boards/unarchive.html", replacements)

    # Un-archive action by post
    confirmed_board_id = request.POST.get("board_id")
    if confirmed_board_id and confirmed_board_id == board_id:
        board.unarchive()
        return HttpResponseRedirect(reverse("boards:view_boards"))

    raise Http404

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def edit(request, board_id, workflow_id):
    member = request.user.member
    board = get_user_boards(request.user).get(id=board_id)
    workflow = board.workflows.get(id=workflow_id)

    if request.method == "POST":
        form = EditWorkflowForm(workflow, request.POST, instance=workflow)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:view_workflows", args=(board_id,)))

    else:
        form = EditWorkflowForm(workflow, instance=workflow)

    return render(request, "workflows/edit.html", {"form": form, "board": board, "workflow": workflow, "member": member})

3 View Complete Implementation : cards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    card = Card(board=board, list=board.first_list)
    card.member = member

    if request.method == "POST":
        form = NewCardForm(request.POST, instance=card, member=member)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:view", args=(board_id,)))
    else:
        form = NewCardForm(instance=card, member=member)

    return render(request, "boards/cards/new.html", {"form": form, "board": board, "member": member})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def delete(request, board_id, workflow_id):
    member = request.user.member
    board = get_user_boards(request.user).get(id=board_id)
    confirmed_workflow_id = request.POST.get("workflow_id")
    if confirmed_workflow_id and confirmed_workflow_id == workflow_id:
        workflow = board.workflows.get(id=confirmed_workflow_id)
        workflow.delete()
        return HttpResponseRedirect(reverse("boards:view_workflows", args=(board_id,)))

    raise Http404

3 View Complete Implementation : noise_measurements.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request):
    member = request.user.member

    noise_measurement = NoiseMeasurement(member=member)

    if request.method == "POST":
        form = NewNoiseMeasurementForm(request.POST, instance=noise_measurement)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("dev_environment:index"))
    else:
        form = NewNoiseMeasurementForm(instance=noise_measurement)

    return render(request, "dev_environment/noise_measurements/new.html", {"form": form, "member": member})

3 View Complete Implementation : admin.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def build_forecaster(request):
    member = request.user.member
    if request.method == "POST":
        form = BuildForecasterForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("forecasters:index"))
    else:
        form = BuildForecasterForm()

    return render(request, "forecasters/build.html", {"form": form, "member": member})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@login_required
def notify_completions(request):
    member = None
    if user_is_member(request.user):
        member = request.user.member
    if request.method == "POST":
        form = NotificationCompletionSenderForm(request.POST, member=member)

        if form.is_valid():
            form.send()
            return HttpResponseRedirect(reverse("work_hours_packages:view_list"))
    else:
        form = NotificationCompletionSenderForm(member=member)

    replacements = {"form": form, "member": member}
    return render(request, "work_hours_packages/notify_completions.html", replacements)

3 View Complete Implementation : auth.py
Copyright MIT License
Author : diegojromerolopez
def login(request):
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            user = form.cleaned_data["user"]
            django_login(request, user)
            return HttpResponseRedirect(reverse("index"))
    else:
        form = LoginForm()

    return render(request, "base/auth/login.html", {"form": form})

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
@inventory_admin_required
def edit_item(request, inventory, item_pk=None):
    item = None
    if item_pk:
        item = get_object_or_404(Item, pk=item_pk)

        if item.inventory != inventory:
            raise Http404()

    form = ItemForm(request.POST or None, instance=item, inventory=inventory)

    if form.is_valid():
        # TODO: handle unique_together constraint
        form.save()
        return HttpResponseRedirect(reverse('inventory:inventory_items',
                                    args=[inventory.pk]))

    context = {'form': form}
    return render(request, 'inventory/admin/edit_item.html', context)

3 View Complete Implementation : cards.py
Copyright MIT License
Author : diegojromerolopez
def _move(request, board_id, card_id, movement_type="forward"):
    if request.method != "POST":
        raise Http404

    member = request.user.member
    try:
        board = get_user_boards(request.user).get(id=board_id)
        card = board.cards.get(id=card_id)
    except (Board.DoesNotExist, Card.DoesNotExist) as e:
        raise Http404

    if movement_type == "forward":
        card.move_forward(member)
    elif movement_type == "backward" or movement_type == "back":
        card.move_backward(member)
    else:
        raise Http404

    return HttpResponseRedirect(reverse("boards:view_card", args=(board_id, card_id)))

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
@inventory_admin_required
def delete_item(request, inventory, item_pk):
    item = get_object_or_404(Item, pk=item_pk)

    if item.inventory != inventory:
        raise Http404()

    form = ItemDeleteForm(request.POST or None, instance=item)

    if form.is_valid():
        form.delete()
        return HttpResponseRedirect(reverse('inventory:inventory_items',
                                    args=[inventory.pk]))

    # render page
    context = {'item': item,
               'form': form}
    return render(request, 'inventory/admin/delete_item.html', context)

3 View Complete Implementation : interruptions.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request):
    member = request.user.member

    interruption = Interruption(member=member)

    if request.method == "POST":
        form = NewInterruptionForm(request.POST, instance=interruption)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("dev_environment:index"))
    else:
        form = NewInterruptionForm(instance=interruption)

    return render(request, "dev_environment/interruptions/new.html", {"form": form, "member": member})

3 View Complete Implementation : models.py
Copyright MIT License
Author : diegojromerolopez
def delete(request, instance, form_clast, next_url, template_path="base/forms/delete.html", template_replacements=None):
    if request.method == "POST":
        form = form_clast(request.POST)

        if form.is_valid() and form.cleaned_data.get("confirmed"):
            instance.delete()
            return HttpResponseRedirect(next_url)

    else:
        form = form_clast()

    instance.meta_verbose_name = instance._meta.verbose_name

    replacements = {"form": form, "instance": instance}
    if template_replacements:
        replacements.update(template_replacements)
    return render(request, template_path, replacements)

3 View Complete Implementation : interruptions.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def delete(request, interruption_id):
    member = request.user.member
    interruption = Interruption.objects.get(id=interruption_id)

    if request.method == "POST":
        form = DeleteInterruptionForm(request.POST)

        if form.is_valid() and form.cleaned_data.get("confirmed"):
            interruption.delete()
            return HttpResponseRedirect(reverse("dev_environment:index"))

    else:
        form = DeleteInterruptionForm()

    replacements = {"form": form, "member": member, "interruption": interruption}
    return render(request, "dev_environment/interruptions/delete.html", replacements)

3 View Complete Implementation : main.py
Copyright MIT License
Author : diegojromerolopez
@login_required
def new(request):
    member = None
    if user_is_member(request.user):
        member = request.user.member

    user = User()

    if request.method == "POST":
        form = NewUserForm(request.POST, instance=user)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("visitors:view_list"))
    else:
        form = NewUserForm(instance=user)

    return render(request, "visitors/new.html", {"form": form, "user": user, "member": member})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    requirement = Requirement(board=board)

    if request.method == "POST":
        form = NewRequirementForm(request.POST, instance=requirement)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:requirements:view_requirements", args=(board_id,)))
    else:
        form = NewRequirementForm(instance=requirement)

    return render(request, "requirements/new.html", {"form": form, "board": board, "member": member})

3 View Complete Implementation : multiboards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def delete(request, multiboard_id):
    member = request.user.member
    try:
        multiboard = member.created_multiboards.get(id=multiboard_id)
    except Multiboard.DoesNotExist:
        raise Http404

    if request.method == "POST":
        form = DeleteMultiboardForm(request.POST)

        if form.is_valid() and form.cleaned_data.get("confirmed"):
            multiboard.delete()
            return HttpResponseRedirect(reverse("multiboards:list"))

    else:
        form = DeleteMultiboardForm()

    return render(request, "multiboards/delete.html", {"form": form, "multiboard": multiboard, "member": member})

3 View Complete Implementation : models.py
Copyright MIT License
Author : diegojromerolopez
def edit(request, instance, form_clast, template_path, ok_url, extra_form_parameters=None):
    if extra_form_parameters is None:
        extra_form_parameters = {}

    if request.method == "POST":
        form = form_clast(request.POST, request.FILES, instance=instance, **extra_form_parameters)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(ok_url)
    else:
        form = form_clast(instance=instance, **extra_form_parameters)

    replacements = {"form": form, "instance": instance}
    replacements.update(extra_form_parameters)
    return render(request, template_path, replacements)

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@login_required
def delete(request, hourly_rate_id):
    member = None
    if user_is_member(request.user):
        member = request.user.member

    hourly_rate = HourlyRate.objects.get(id=hourly_rate_id)

    if request.method == "POST":
        form = DeleteHourlyRateForm(request.POST)

        if form.is_valid():
            hourly_rate.delete()
            return HttpResponseRedirect(reverse("hourly_rates:view_hourly_rates"))

    else:
        form = DeleteHourlyRateForm()

    return render(request, "hourly_rates/delete.html", {"form": form, "member": member, "hourly_rate": hourly_rate})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def edit_entry(request, board_id, year, month, journal_entry_slug):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)
    journal_entry = get_object_or_404(
        JournalEntry, creation_datetime__year=year, creation_datetime__month=month, slug=journal_entry_slug
    )

    if request.method == "POST":
        form = EditJournalEntryForm(request.POST, instance=journal_entry)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:journal:view", args=(board_id,)))
    else:
        form = EditJournalEntryForm(instance=journal_entry)

    replacements = {"form": form, "board": board, "member": member, "journal_entry": journal_entry}
    return render(request, "journal/entries/edit.html", replacements)

3 View Complete Implementation : multiboards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def edit(request, multiboard_id):
    member = request.user.member
    try:
        multiboard = member.created_multiboards.get(id=multiboard_id)
    except Multiboard.DoesNotExist:
        raise Http404

    if request.method == "POST":
        form = MultiboardForm(request.POST, instance=multiboard)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("multiboards:list"))

    else:
        form = MultiboardForm(instance=multiboard)

    return render(request, "multiboards/edit.html", {"form": form, "multiboard": multiboard, "member": member})

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def create_default_labels(request, board_id):
    member = request.user.member

    # Only members with credentials can sync their boards
    if member.has_trello_profile:
        return HttpResponseRedirect(reverse("boards:view", args=(board_id,)))

    if request.method != "POST":
        return HttpResponseRedirect(reverse("boards:view", args=(board_id,)))

    board = get_user_boards(request.user).get(id=board_id)
    if board.labels.all().exists():
        return HttpResponseRedirect(reverse("boards:view", args=(board_id,)))

    Label.create_default_labels(board)

    return HttpResponseRedirect(reverse("boards:view_label_report", args=(board_id,)))

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def edit(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    if request.method == "POST":
        form = EditBoardForm(request.POST, request.FILES, instance=board)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse("boards:view", args=(board_id,)))

    else:
        form = EditBoardForm(instance=board)

    replacements = {"board": board, "member": member, "form": form}
    return render(request, "boards/edit.html", replacements)

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new_mood_measurement(request):
    member = request.user.member
    today = timezone.now().date()

    daily_member_mood = DailyMemberMood(member=member, date=today)

    if request.method == "POST":
        form = NewDailyMemberMoodForm(request.POST, instance=daily_member_mood)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("niko_niko_calendar:view_calendar"))
    else:
        form = NewDailyMemberMoodForm(instance=daily_member_mood)

    replacements = {"form": form, "today": today, "member": member, "date": today}
    return render(request, "niko_niko_calendar/new_mood_measurement.html", replacements)

3 View Complete Implementation : multiboards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request):
    member = request.user.member

    multiboard = Multiboard(creator=member)

    if request.method == "POST":
        form = MultiboardForm(request.POST, instance=multiboard)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("multiboards:list"))
    else:
        form = MultiboardForm(instance=multiboard)

    return render(request, "multiboards/new.html", {"form": form, "member": member})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request, board_id):
    member = request.user.member
    board = get_user_boards(request.user).get(id=board_id)
    workflow = Workflow(name=u"New workflow", board=board)

    if request.method == "POST":
        form = NewWorkflowForm(workflow, request.POST)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:view_workflows", args=(board_id,)))

    else:
        form = NewWorkflowForm(workflow)

    return render(request, "workflows/new.html", {"form": form, "board": board, "member": member})

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request):
    member = request.user.member
    board = Board(creator=member)

    if request.method == "POST":
        form = NewBoardForm(request.POST, instance=board, member=member)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:view_boards"))
    else:
        form = NewBoardForm(instance=board, member=member)

    return render(request, "boards/new.html", {"form": form, "board": board, "member": member})

3 View Complete Implementation : views.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request):
    member = request.user.member
    hourly_rate = HourlyRate(creator=member)

    if request.method == "POST":
        form = HourlyRateForm(request.POST, instance=hourly_rate)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("hourly_rates:view_hourly_rates"))

    else:
        form = HourlyRateForm(instance=hourly_rate)

    return render(request, "hourly_rates/new.html", {"form": form, "member": member})

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def archive(request, board_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    # Show archive form
    if request.method == "GET":
        replacements = {"member": member, "board": board}
        return render(request, "boards/archive.html", replacements)

    # Archive action by post
    confirmed_board_id = request.POST.get("board_id")
    if confirmed_board_id and confirmed_board_id == board_id:
        board.archive()
        return HttpResponseRedirect(reverse("boards:view_boards"))

    raise Http404

3 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def init_boards(request):
    if request.method == "POST":
        member = request.user.member
        initializer = Initializer(member)
        initializer.init()
        return HttpResponseRedirect(reverse("boards:view_boards"))

    raise Http404

3 View Complete Implementation : cards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def download_attachment(request, board_id, card_id, attachment_id):
    if request.method != "GET":
        raise Http404
    try:
        board = get_user_boards(request.user).get(id=board_id)
        card = board.cards.get(id=card_id)
        attachment = card.attachments.get(id=attachment_id)
    except (Board.DoesNotExist, Card.DoesNotExist, CardAttachment.DoesNotExist) as e:
        raise Http404

    if not attachment.file:
        attachment.fetch_external_file()

    return HttpResponseRedirect(attachment.file.url)

3 View Complete Implementation : admin.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
@inventory_admin_required
def edit_inventory(request, inventory=None):
    # permission checking is done in inventory_admin_required
    form = InventoryForm(request.POST or None, instance=inventory)

    if form.is_valid():
        form.save()
        return HttpResponseRedirect(reverse('inventory:inventory_list'))

    # render page
    context = {'form': form}
    return render(request, 'inventory/admin/edit_inventory.html', context)

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
@login_required
def create_issue(request):
    form = IssueForm(request.POST or None, user=request.user)

    if form.is_valid():
        try:
            form.save()
            messages.success(request, _("The issue was saved and sent to the "
                                        "admins."))
        except (SMTPException, ConnectionError) as e:
            messages.error(request, _("The issue was created but notifying "
                                      "the admins failed: %(error)s") %
                           {'error': str(e)})

        return HttpResponseRedirect(reverse('help:create_issue'))

    context = {'form': form}
    return render(request, 'help/create_issue.html', context)

3 View Complete Implementation : auth.py
Copyright MIT License
Author : diegojromerolopez
def reset_pastword(request):
    if request.method == "POST":
        form = ResetPastwordForm(request.POST)
        if form.is_valid():
            member = form.cleaned_data["member"]
            pastword = member.reset_pastword()
            _send_new_pastword_to_member(member, pastword)
            return HttpResponseRedirect(reverse("members:reset_pastword_success"))
    else:
        form = ResetPastwordForm()
    return render(request, "members/reset_pastword.html", {"form": form})

3 View Complete Implementation : auth.py
Copyright MIT License
Author : diegojromerolopez
@transaction.atomic
def local_signup(request):

    if request.method == "POST":
        form = LocalSignUpForm(request.POST)

        if form.is_valid():
            member = form.save(commit=True)
            user = authenticate(username=member.user.username, pastword=form.data["pastword1"])
            if user and user is not None:
                django_login(request, user)
                return HttpResponseRedirect(reverse("index"))

    else:
        form = LocalSignUpForm()

    return render(request, "members/signup/local_signup.html", {"form": form})

3 View Complete Implementation : repositories.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def checkout(request, board_id, repository_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)
    try:
        repository = board.repositories.get(id=repository_id)
    except ObjectDoesNotExist:
        raise Http404

    repository.checkout()
    return HttpResponseRedirect(reverse("boards:repositories:view_repository", args=(board_id, repository.id)))

3 View Complete Implementation : noise_measurements.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def delete(request, noise_measurement_id):
    member = request.user.member
    noise_measurement = NoiseMeasurement.objects.get(id=noise_measurement_id)

    if request.method == "POST":
        form = DeleteNoiseMeasurementForm(request.POST)

        if form.is_valid() and form.cleaned_data.get("confirmed"):
            noise_measurement.delete()
            return HttpResponseRedirect(reverse("dev_environment:index"))

    else:
        form = DeleteNoiseMeasurementForm()

    replacements = {"form": form, "member": member, "noise_measurement": noise_measurement}
    return render(request, "dev_environment/noise_measurements/delete.html", replacements)

0 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def edit_label(request, board_id, label_id):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)
    try:
        label = board.labels.get(id=label_id)
    except Label.DoesNotExist:
        raise Http404

    if request.method == "POST":
        form = LabelForm(request.POST, instance=label)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse("boards:view_label_report", args=(board_id,)))

    else:
        form = LabelForm(instance=label)

    replacements = {"board": board, "member": member, "form": form, "label": label}
    return render(request, "boards/labels/edit.html", replacements)

0 View Complete Implementation : cards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def add_comment(request, board_id, card_id):
    if request.method != "POST":
        raise Http404
    member = request.user.member
    try:
        board = get_user_boards(request.user).get(id=board_id)
        card = board.cards.get(id=card_id)
    except (Board.DoesNotExist, Card.DoesNotExist) as e:
        raise Http404

    # Getting the comment content
    comment_content = request.POST.get("comment")

    # If the comment is empty, redirect to card view
    if not comment_content:
        return HttpResponseRedirect(reverse("boards:view_card", args=(board_id, card_id)))

    # Otherwise, add the comment
    card.add_comment(member, comment_content)
    return HttpResponseRedirect(reverse("boards:view_card", args=(board_id, card_id)))

0 View Complete Implementation : boards.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new_list(request, board_id):
    member = None
    if user_is_member(request.user):
        member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    list_ = List(board=board)

    # Setting maximum position of this new list (this list will be the last)
    lists = board.lists.all().order_by("-position")
    if lists.exists():
        list_.position = lists[0].position + 10

    if request.method == "POST":
        form = NewListForm(request.POST, instance=list_, member=member)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:view_lists", args=(board_id,)))
    else:
        form = NewListForm(instance=list_, member=member)

    return render(request, "boards/lists/new.html", {"form": form, "board": board, "member": member})

0 View Complete Implementation : repositories.py
Copyright MIT License
Author : diegojromerolopez
@member_required
def new(request, board_id, type="gitlab"):
    member = request.user.member
    board = get_user_board_or_404(request.user, board_id)

    if type == "gitlab":
        repository_clast = GitLabRepository
        form_clast = GitLabRepositoryForm
    elif type == "github":
        repository_clast = GitHubPublicRepository
        form_clast = GitHubPublicRepositoryForm
    else:
        raise Http404

    repository = repository_clast(board=board)

    if request.method == "POST":
        form = form_clast(request.POST, instance=repository)

        if form.is_valid():
            form.save(commit=True)
            return HttpResponseRedirect(reverse("boards:repositories:view_repositories", args=(board_id,)))
    else:
        form = form_clast(instance=repository)

    return render(request, "repositories/new.html", {"form": form, "board": board, "member": member})