示例#1
0
def edit_page(request, vanity_url):
    if request.user.is_authenticated():
        page = Page.objects.get(vanity_url=vanity_url)
        connections = page.connections

        if request.method == 'POST':
            form = PageForm(request.POST, instance=page)
            if form.is_valid():
                page.location = form.cleaned_data['location']
                page.type = form.cleaned_data['type']
                page.name = form.cleaned_data['name']
                page.tags = form.cleaned_data['tags']
                page.description = form.cleaned_data['description']
                page.homepage = form.cleaned_data['homepage']
                page.date_established = form.cleaned_data['date_established']
                page.save()
        else:
            form = PageForm(instance=page)

        # Setup for the stories
        story_form = StoryForm()
        story_types = Story.types()
        # Grab all of the existing stories and create a hash of 'title' => Form for editing.
        stories = Story.objects.filter(page=page, deleted=False)
        story_forms = []
        for story in stories:
            story_forms.append(StoryForm(instance=story))

    return locals()
示例#2
0
def edit_page(request, vanity_url):
    if request.user.is_authenticated():
        page = Page.objects.get(vanity_url=vanity_url)
        connections = page.connections

        if request.method == 'POST':
            form = PageForm(request.POST, instance=page)
            if form.is_valid():
                page.location = form.cleaned_data['location']
                page.type = form.cleaned_data['type']
                page.name = form.cleaned_data['name']
                page.tags = form.cleaned_data['tags']
                page.description = form.cleaned_data['description']
                page.homepage = form.cleaned_data['homepage']
                page.date_established = form.cleaned_data['date_established']
                page.save()
        else:
            form = PageForm(instance=page)

        # Setup for the stories
        story_form = StoryForm()
        story_types = Story.types()
        # Grab all of the existing stories and create a hash of 'title' => Form for editing.
        stories = Story.objects.filter(page=page, deleted=False)
        story_forms = []
        for story in stories:
            story_forms.append(StoryForm(instance=story))

    return locals()
示例#3
0
def add_page(request):
    if not request.user.is_authenticated():
        return redirect('/accounts/login/')
    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            # Create the Page
            page = create_page(form, request)
            page.save()
            return redirect('/edit/page/{}'.format(page.vanity_url))
        else:
            logger.log("Form Errors: ", form.errors)
    else:
        form = PageForm()

    return locals()
示例#4
0
def add_page(request):
    if not request.user.is_authenticated():
        return redirect('/accounts/login/')
    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            # Create the Page
            page = create_page(form, request)
            page.save()
            return redirect('/edit/page/{}'.format(page.vanity_url))
        else:
            logger.log("Form Errors: ", form.errors)
    else:
        form = PageForm()

    return locals()