Exemple #1
0
def edit_quest(request, quest_id):
    quest = get_object_or_404(Quest, pk=quest_id)
    request = is_quest_organizer(request, quest)
    if request.method == "POST":
        form = QuestForm(request.POST, instance=quest)
        if form.is_valid():
            form.save()
            if quest.parent:
                return redirect('coordination:line_detail', quest_id=quest.parent.id, line_id=quest.id)
            else:
                return redirect('coordination:quest_detail', quest_id=quest.id)
    else:
        form = QuestForm(instance=quest)
    context = {'form': form}
    return render(request, 'coordination/quests/form.html', context)
Exemple #2
0
def create_quest(request, type=Quest.LINEAR):
    request = is_organizer(request)
    if request.method == 'POST':
        form = QuestForm(request.POST)
        if form.is_valid():
            quest = form.save(commit=False)
            quest.creator = request.user
            quest.type = type
            quest.save()
            return redirect('coordination:quest_detail', quest_id=quest.pk)
    else:
        form = QuestForm(type=type)
    context = {'form': form}
    return render(request, 'coordination/quests/form.html', context)
Exemple #3
0
def create_line(request, quest_id, type=Quest.LINEAR):
    quest = get_object_or_404(Quest, pk=quest_id, type=Quest.MULTILINEAR)
    request = is_quest_organizer(request, quest)
    if request.method == 'POST':
        form = QuestForm(request.POST)
        if form.is_valid():
            line = form.save(commit=False)
            line.creator = quest.creator
            line.type = type
            line.parent = quest
            line.save()
            return redirect('coordination:line_detail', quest_id=quest.id, line_id=line.pk)
    else:
        form = QuestForm(type=type, parent=quest)
    context = {'form': form}
    return render(request, 'coordination/quests/form.html', context)