示例#1
0
 def post(self, request):
     form = PageForm(request.POST)
     if form.is_valid():
         newcard = form.save()
         return HttpResponseRedirect(
             reverse_lazy('wiki-details-page', args=[newcard.slug]))
     return render(request, 'addcard.html', {'form': form})
示例#2
0
文件: views.py 项目: Aliezen/language
def addPage(request, categoryID):
    template = 'wiki/addPage.html'
    try:
        pageCategory = Category.objects.get(id=int(categoryID))
    except Category.DoesNotExist:
        return category(request, categoryID)
    context = {'category':pageCategory}
    if request.method=='GET':
        context['form'] = PageForm()
        return render(request, template, context)
    # request.method=='POST
    
    form = PageForm(request.POST)
    context['form'] = form

    if not form.is_valid():
        context['error'] = "error"
        return render(request, template, context)
    
    page = form.save(commit=False)
    page.category = pageCategory
    page.save()
    context['error'] = "pass"
    #return render(request, template, context)
    return redirect(reverse('wiki:category', args=(categoryID, )))
示例#3
0
 def post(self, request, *args, **kwargs):
     form = PageForm(request.POST)
     if form.is_valid():
         new_Page = form.save()
         new_Page.save()
         return HttpResponseRedirect(reverse_lazy('wiki-list-page'))
     return render(request, 'createPage.html', {'form': form})
示例#4
0
 def post(self, request, *args, **kwargs):
     form = PageForm(request.POST)
     if form.is_valid():
         page = form.save()
         return HttpResponseRedirect(
             reverse_lazy('wiki-details-page', args=[page.slug]))
     return render(request, 'page_new.html', {'form': form})
示例#5
0
 def post(self, request):
     if request.method == 'POST':
         form = PageForm(request.POST)
         if form.is_valid():
             article = form.save()
             return HttpResponseRedirect(
                 reverse_lazy('wiki-details-page', args=[article.slug]))
         return render(request, 'new_page.html', {'form': form})
示例#6
0
 def post(self, request):
     page_form = PageForm(request.POST)
     if page_form.is_valid():
         page = page_form.save(commit=False)
         page.author = User.objects.get(id=request.POST['author'])
         page.save()
         return HttpResponseRedirect(reverse_lazy('wiki-create-page'))
     else:
         return render(request, self.template_name, {'form': page_form})
示例#7
0
    def post(self, request):
        form = PageForm(request.POST)
        if form.is_valid:
            page = form.save()
            page.save()
            return HttpResponseRedirect(
                reverse('wiki-details-page', args=[page.slug]))

        return render(request, 'create.html', {'form': form})
示例#8
0
    def post(self, request, slug):
        #TODO: figure out what's wrong with the submit
        if request.method == 'POST':
            data = PageForm(request.POST)
            if data.is_valid():
                post = data.save(commit=False)
                post.save()

            return (redirect(reverse('wiki-detail-page'), {'form': post}))
示例#9
0
 def post(self, request, *args, **kwargs):
     form = PageForm(request.POST)
     if form.is_valid():
         page = form.save(commit=False)
         page.author = request.user
         page.save()
         # Using slugify here as the url takes in a string and not an Int id
         return HttpResponseRedirect(
             reverse_lazy('wiki-details-page', args=[slugify(page.title)]))
     return render(request, 'new.html', {'form': form})
示例#10
0
    def post(self, request, *args, **kwargs):
        form = PageForm(request.POST)

        if form.is_valid():
            page = form.save()

            return HttpResponseRedirect(reverse_lazy('wiki-list-page'))

        #render the form again if it is not valid
        return render(request, 'newpage.html', {'form': form})
示例#11
0
    def post(self, request, *args, **kwargs):
        form = PageForm(request.POST)

        if form.is_valid:
            Page = form.save(commit=False)
            Page.author = request.user
            Page = form.save()
            return HttpResponseRedirect(
                reverse('wiki-details-page', args=[Page.slug]))
        return render(request, 'create.html', {'form': form})
示例#12
0
文件: views.py 项目: rsenk330/MyWiki
def create(request):
    form = PageForm(request.POST)

    if form.is_valid():
        page = form.save()

        return redirect(page)
    else:
        return render(request, 'new.html', {
            'form': form,
        })
示例#13
0
 def post(self, request):
     """processes the form and adds a wiki """
     form = PageForm(request.POST)
     form.instance.author = self.request.user
     if form.is_valid():
         page = form.save()
         return HttpResponseRedirect(
             reverse('wiki-details-page', args=[page.slug]))
     else:
         return render(request, 'add_page.html', {
             'page_form': form,
         })
示例#14
0
def updatePage(request, pageID=None):
    template = 'wiki/updatePage.html'
    page = get_object_or_404(Page, id=pageID)
    if request.method=='GET':
        form = PageForm(instance=page)
        return render(request, template, {'form':form, 'page':page})
    # request.method=='POST'
    form = PageForm(request.POST, instance=page)
    if not form.is_valid():
        return render(request, template, {'form':form, 'page':page})
    form.save()
    return redirect(reverse('wiki:category', args=(page.category.id,)))
示例#15
0
    def post(self, request, *args, **kwargs):
        #form submitted via post request
        form = PageForm(request.POST)
        #form validation check
        if form.is_valid():
            #save form
            page = form.save()

            #redirect the user to home
            return HttpResponseRedirect(reverse_lazy('wiki-list-page'))

        #render the form again if it is not valid
        return render(request, 'newpage.html', {'form': form})
示例#16
0
    def post(self, request, *args, **kwargs):
        form = PageForm(request.POST)
        print("Form: {}".format(form))

        if form.is_valid():
            print("Form is valid")
            page = form.save(commit=False)
            page.author = request.user
            page.created = timezone.now()
            page.modified = timezone.now()
            page.save()
            return HttpResponseRedirect(reverse_lazy('wiki-list-page'))

        return render(request, 'newpage.html', {'form': form})
示例#17
0
def updatePage(request, pageID):
    template = 'wiki/updatePage.html'
    try:
        page = Page.objects.get(id=pageID)
    except Page.DoesNotExist:
        return category(request, '')
    if request.method=='GET':
        form = PageForm(instance=page)
        return render(request, template, {'form':form, 'page':page})
 # request.method=='POST'
    form = PageForm(request.POST, instance=page)
    if not form.is_valid():
        return render(request, template, {'form':form, 'page':page})
    page.save()
    return redirect(reverse('wiki:category', args=(page.category.id,)))
示例#18
0
def updatePage(request, pageID):
    template = 'wiki/updatePage.html'
    try:
        page = Page.objects.get(id=pageID)
    except Page.DoesNotExist:
        return category(request, '')
    if request.method == 'GET':
        form = PageForm(instance=page)
        return render(request, template, {'form': form, 'page': page})
# request.method=='POST'
    form = PageForm(request.POST, instance=page)
    if not form.is_valid():
        return render(request, template, {'form': form, 'page': page})
    page.save()
    return redirect(reverse('wiki:category', args=(page.category.id, )))
示例#19
0
def updatePage(request, pageID):
    template = "wiki/updatePage.html"
    try:
        page = Page.objects.get(id=pageID)
    except Page.DoesNotExist:
        return category(request, "")
    if request.method == "GET":
        form = PageForm(instance=page)
        return render(request, template, {"form": form, "page": page})
    # request.method=='POST'
    form = PageForm(request.POST, instance=page)
    if not form.is_valid():
        return render(request, template, {"form": form, "page": page})
    form.save()
    return redirect(reverse("wiki:category", args=(page.category.id,)))
示例#20
0
文件: views.py 项目: rsenk330/MyWiki
def edit(request, title):
    page = Page.objects.get(title__iexact=title)

    if request.method == 'POST':
        form = PageForm(
            request.POST, instance=Page.objects.get(title__iexact=title))

        if form.is_valid():
            page = form.save()

            return redirect(page)
    else:
        form = PageForm(instance=page)

    return render(request, 'edit.html', {'page': page, 'form': form})
示例#21
0
def addPage(request, categoryID=None):
    template = 'wiki/addPage.html'
    pageCategory = get_object_or_404(Category, id=categoryID)
    context = {'category':pageCategory}
    if request.method=='GET':
        context['form'] = PageForm()
        return render(request, template, context)
    # request.method=='POST' 
    form = PageForm(request.POST)
    context['form'] = form
    if not form.is_valid():
        return render(request, template, context)
    page = form.save(commit=False)
    page.category = pageCategory
    page.save()
    return redirect(reverse('wiki:category', args=(categoryID, )))
示例#22
0
def page_form(request, parent_page_id):
	print 
	if request.method == 'GET':
		form = PageForm()
	else:
		form = PageForm(request.POST)
		if form.is_valid():
			content = form.cleaned_data['content']
			title = form.cleaned_data['title']
			parent_page = DefaultPage.objects.get(pk=parent_page_id)
			print parent_page_id
			print parent_page
			post = Page.objects.create(body=content,title=title,parent_page=parent_page)

			return HttpResponseRedirect(reverse('index', ))
	return render(request, 'wiki/page_form.html', {'form': form,})	
示例#23
0
    def get(self, request, slug):
        """ Returns a specific of wiki page by slug. """
        article = Page.objects.get(slug=slug)
        form = PageForm(instance=article)

        return (render(request, 'page.html', {
            'article': article,
            'form': form
        }))
示例#24
0
 def get(self, request, slug):
     page = Page.objects.get(slug=slug)
     form = PageForm(
         initial={
             'title': page.title,
             'author': page.author,
             'slug': page.slug,
             'content': page.content
         })
     return render(request, 'wiki/page.html', {'page': page, 'form': form})
示例#25
0
def addPage(request, categoryID):
    template = "wiki/addPage.html"
    try:
        pageCategory = Category.objects.get(id=int(categoryID))
    except Category.DoesNotExist:
        return category(request, categoryID)
    context = {"category": pageCategory}
    if request.method == "GET":
        context["form"] = PageForm()
        return render(request, template, context)
    # request.method=='POST'
    form = PageForm(request.POST)
    context["form"] = form
    if not form.is_valid():
        return render(request, template, context)
    page = form.save(commit=False)
    page.category = pageCategory
    page.save()
    return redirect(reverse("wiki:category", args=(categoryID,)))
示例#26
0
文件: views.py 项目: omeinusch/Palco
def page_form(request, page_slug):
    try:
        page = Page.objects.get_by_owner(page_slug, request)
    except PermissionDenied:
        return redirect(Page.objects.get(slug=page_slug))
    except Page.DoesNotExist:
        return redirect('wiki-page', page_slug=page_slug)

    if request.POST:
        form = PageForm(request.POST, instance=page)
        if form.is_valid():
            form.save()
            message_object_updated(request, page)
            return redirect(page)
    else:
        form = PageForm(instance=page)

    return render(request, 'wiki/page-form.html',
                  get_context_wiki(request, 'wiki-page-form', {'form': form, 'page': page}))
示例#27
0
def addPage(request, categoryName):
    template = 'wiki/addPage.html'
    try:
        pageCategory = Category.objects.get(name=categoryName)
    except Category.DoesNotExist:
        return category(request, categoryName)
    context = {'category': pageCategory}
    if request.method == 'GET':
        context['form'] = PageForm()
        return render(request, template, context)
    # request.method=='POST'
    form = PageForm(request.POST)
    context['form'] = form
    if not form.is_valid():
        return render(request, template, context)
    page = form.save(commit=False)
    page.category = pageCategory
    page.save()
    return redirect(reverse('wiki:category', args=(categoryName, )))
示例#28
0
文件: views.py 项目: zouf/AllSortz
def edit_master_tag_discussion(request,bus_id,page_id):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/accounts/login/?next=%s'%request.path)
        
    b = get_object_or_404(Business, pk=bus_id)
    page = get_object_or_404(Page, pk=page_id)

    try:
        b.photourl = get_photo_web_url(b)
    except:
        b.photourl= "" #NONE


    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            if not page:
                page = Page()
            page.content = form.cleaned_data['content']

            page.save()
            return redirect(bus_details, bus_id=bus_id)
    else:
        if page:
            wiki_edit_form = PageForm(initial=page.__dict__)
        else:
            wiki_edit_form = PageForm(initial={'name': page.name})

    
    try:
        pgr = PageRelationship.objects.get(page=page)
    except:
        pgr = PageRelationship.objects.filter(page=page)[0]
    t = pgr.businesstag
    context = get_default_bus_context(b, request.user)
    context['form']=wiki_edit_form
    context['page']=page
    context['tag'] =t 
    

    
    return render_to_response('ratings/busdetail.html', context_instance=RequestContext(request,context))
示例#29
0
    def test_page_create(self):
        # check that the creation page form loads when visiting
        response = self.client.get('/new/')
        self.assertEqual(response.status_code, 200)

        form = PageForm()
        self.assertTrue(form)

        self.assertIn(b'Title of your page.', response.content)
        self.assertIn(b'Write the content of your page here.',
                      response.content)
示例#30
0
 def post(self, request, slug):
     form = PageForm(request.POST)
     if form.is_valid():
         obj = Page()
         obj.title = form.cleaned_data['title']
         obj.author = form.cleaned_data['author']
         obj.slug = form.cleaned_data['slug']
         obj.email = form.cleaned_data['email']
         obj.content = form.cleaned_data['content']
         obj.save()
         messages.add_message(request, messages.INFO,
                              obj.title + ' has been successfully updated')
         return HttpResponseRedirect(reverse('wiki-list-page'))
     else:
         form = PageForm()
         page = Page.objects.get(slug=slug)
         return render(request, 'wiki/page.html', {
             'page': page,
             'form': form
         })
示例#31
0
    def post(self, request, slug):
        form = PageForm(request.POST)
        page = self.get_queryset().get(slug__iexact=slug)
        if form.is_valid:
            page.title = request.POST['title']
            page.content = request.POST['content']
            page.author = request.user

            page.save()
            return HttpResponseRedirect(
                reverse('wiki-details-page', args=[page.slug]))
        # else if form is not valid
        return render(request, 'wiki-details-page', {'form': form})
示例#32
0
    def post(self, request, slug):

        form = PageForm(request.POST)

        page = self.get_queryset().get(slug__iexact=slug)

        page.title = request.POST['title']
        page.content = request.POST['content']
        page.author = request.user
        page.save()

        return HttpResponseRedirect(
            reverse('wiki-details-page', args=[page.slug]))
示例#33
0
    def post(self, req, slug):
        '''Edit the page's information'''
        form = PageForm(req.POST)  # create a form

        page = self.get_queryset().get(slug__iexact=slug)
        page.title = req.POST['title']  # retrieve the page's title
        page.content = req.POST['content']  # retrieve the page's content
        page.author = req.user  # get the author of the user
        page.slug = slugify(page.title)  # create a new slug to match title
        page.save()  # saves our new post

        # We load the wiki details page and the url will be the title's slug
        return HttpResponseRedirect(
            reverse('wiki-details-page', args=[page.slug]))
示例#34
0
    def test_page_form_post(self):
        #get a user object
        user = User.objects.create()

        #make a form dictionary
        form = {
            'title': "My Test Page",
            'content': "testing",
            'author': user.id
        }

        response = self.client.post('/new/', form=form)
        self.assertEqual(response.status_code, 302)  #not working

        #create a page form with the form data and check if it's valid
        form_page = PageForm(data=form)
        form_page.save()
        self.assertTrue(form_page.is_valid())

        users = User.objects.all()
        self.assertEqual(len(users), 1)

        #check if the form is saved in the test db
        page = Page.objects.get(title='My Test Page')
示例#35
0
    def post(self, request, slug, *args, **kwargs):
        form = PageForm(request.POST)

        if form.is_valid:
            Page = self.get_queryset().get(slug__iexact=slug)
            Page.title = request.POST['title']
            Page.content = request.POST['content']
            Page.modified = datetime.now()
            Page.slug = slugify(Page.title, allow_unicode=True)
            # Page = form.save(commit=False)
            Page.author = request.user
            Page.save()
            return HttpResponseRedirect(
                reverse('wiki-details-page', args=[Page.slug]))
        return render(request, 'page.html', {'form': form})
示例#36
0
 def get(self, request, *args, **kwargs):
     #get form
     context = {'form': PageForm()}
     #pass form to wiki/newpage and render template
     return render(request, 'newpage.html', context)
示例#37
0
 def get(self, request):
     context = {'form': PageForm(request.POST)}
     return render(request, 'new_page.html', context)
示例#38
0
 def get(self, request):
     form = PageForm()
     return render(request, 'new_page.html', {'form': form})
示例#39
0
    def get(self, request, slug):
        """ Returns a specific wiki page by slug. """
        page = self.get_queryset().get(slug__iexact=slug)
        form = PageForm()

        return render(request, 'page.html', {'page': page, 'form': form})
示例#40
0
 def get(self, request):
     context = {'form': PageForm()}
     return render(request, 'create.html', context)