예제 #1
0
파일: views.py 프로젝트: PhobosXIII/qc
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)
예제 #2
0
파일: views.py 프로젝트: PhobosXIII/qc
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)
예제 #3
0
파일: views.py 프로젝트: PhobosXIII/qc
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)