Beispiel #1
0
def change_moderation(request, page_id):
    """Called when user clicks on a moderation checkbox in tree vies, so if he
    wants to add/remove/change moderation required by him. Moderate is sum of
    mask values.
    """
    page = get_object_or_404(Page, id=page_id)
    moderate = request.POST.get('moderate', None)
    if moderate is not None and page.has_moderate_permission(request):
        try:
            moderate = int(moderate)
        except:
            moderate = 0
        
        if moderate == 0:
            # kill record with moderation which equals zero
            try:
                page.pagemoderator_set.get(user=request.user).delete()
            except ObjectDoesNotExist:
                pass
            return render_admin_menu_item(request, page)
        elif moderate <= MASK_PAGE + MASK_CHILDREN + MASK_DESCENDANTS:
            page_moderator, created = page.pagemoderator_set.get_or_create(user=request.user)
            # split value to attributes
            page_moderator.set_decimal(moderate)
            page_moderator.save()
            return render_admin_menu_item(request, page)
    raise Http404
Beispiel #2
0
def change_moderation(request, page_id):
    """Called when user clicks on a moderation checkbox in tree vies, so if he
    wants to add/remove/change moderation required by him. Moderate is sum of
    mask values.
    """
    page = get_object_or_404(Page, id=page_id)
    moderate = request.POST.get('moderate', None)
    if moderate is not None and page.has_moderate_permission(request):
        try:
            moderate = int(moderate)
        except:
            moderate = 0
        
        if moderate == 0:
            # kill record with moderation which equals zero
            try:
                page.pagemoderator_set.get(user=request.user).delete()
            except ObjectDoesNotExist:
                pass
            return render_admin_menu_item(request, page)
        elif moderate <= MASK_PAGE + MASK_CHILDREN + MASK_DESCENDANTS:
            page_moderator, created = page.pagemoderator_set.get_or_create(user=request.user)
            # split value to attributes
            page_moderator.set_decimal(moderate)
            page_moderator.save()
            return render_admin_menu_item(request, page)
    raise Http404
Beispiel #3
0
def change_status(request, page_id):
    """
    Switch the status of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_publish_permission(request):
        page.published = not page.published
        page.save()    
        return render_admin_menu_item(request, page)
    raise Http404
Beispiel #4
0
def change_status(request, page_id):
    """
    Switch the status of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_publish_permission(request):
        page.published = not page.published
        page.save(force_state=Page.MODERATOR_NEED_APPROVEMENT)    
        return render_admin_menu_item(request, page)
    else:
        return HttpResponseForbidden(_("You do not have permission to publish this page"))
Beispiel #5
0
def change_status(request, page_id):
    """
    Switch the status of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_publish_permission(request):
        page.published = not page.published
        page.save(force_state=Page.MODERATOR_NEED_APPROVEMENT)    
        return render_admin_menu_item(request, page)
    else:
        return HttpResponseForbidden(ugettext("You do not have permission to publish this page"))
Beispiel #6
0
def change_innavigation(request, page_id):
    """
    Switch the in_navigation of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_change_permission(request):
        if page.in_navigation:
            page.in_navigation = False
            val = 0
        else:
            page.in_navigation = True
            val = 1
        page.save()
        return render_admin_menu_item(request, page)
    raise Http404
Beispiel #7
0
def change_innavigation(request, page_id):
    """
    Switch the in_navigation of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_change_permission(request):
        if page.in_navigation:
            page.in_navigation = False
            val = 0
        else:
            page.in_navigation = True
            val = 1
        page.save(force_state=Page.MODERATOR_NEED_APPROVEMENT)
        return render_admin_menu_item(request, page)
    return HttpResponseForbidden(_("You do not have permission to change this page's in_navigation status"))
Beispiel #8
0
def change_innavigation(request, page_id):
    """
    Switch the in_navigation of a page
    """
    page = get_object_or_404(Page, pk=page_id)
    if page.has_change_permission(request):
        if page.in_navigation:
            page.in_navigation = False
            val = 0
        else:
            page.in_navigation = True
            val = 1
        page.save(force_state=Page.MODERATOR_NEED_APPROVEMENT)
        return render_admin_menu_item(request, page)
    return HttpResponseForbidden(ugettext("You do not have permission to change this page's in_navigation status"))
Beispiel #9
0
    def approve_page(self, request, page_id):
        """Approve changes on current page by user from request.
        """        
        #TODO: change to POST method !! get is not safe
        
        page = get_object_or_404(Page, id=page_id)
        if not page.has_moderate_permission(request):
            raise Http404()

        approve_page(request, page)
        
        self.message_user(request, _('Page was successfully approved.'))
        
        if 'node' in request.REQUEST:
            # if request comes from tree..
            return render_admin_menu_item(request, page)
        return HttpResponseRedirect('../../')
Beispiel #10
0
    def approve_page(self, request, page_id):
        """Approve changes on current page by user from request.
        """
        #TODO: change to POST method !! get is not safe

        page = get_object_or_404(Page, id=page_id)
        if not page.has_moderate_permission(request):
            raise Http404()

        approve_page(request, page)

        self.message_user(request, _('Page was successfully approved.'))

        if 'node' in request.REQUEST:
            # if request comes from tree..
            return render_admin_menu_item(request, page)
        return HttpResponseRedirect('../../')
Beispiel #11
0
    def move_page(self, request, page_id, extra_context=None):
        """
        Move the page to the requested target, at the given position
        """
        target = request.POST.get("target", None)
        position = request.POST.get("position", None)
        if target is None or position is None:
            return HttpResponseRedirect("../../")

        try:
            page = self.model.objects.get(pk=page_id)
            target = self.model.objects.get(pk=target)
        except self.model.DoesNotExist:
            return HttpResponseBadRequest("error")

        # does he haves permissions to do this...?
        if not page.has_move_page_permission(request) or not target.has_add_permission(request):
            return HttpResponseForbidden("Denied")

        # move page
        page.move_page(target, position)
        return render_admin_menu_item(request, page)
Beispiel #12
0
    def move_page(self, request, page_id, extra_context=None):
        """
        Move the page to the requested target, at the given position
        """
        target = request.POST.get('target', None)
        position = request.POST.get('position', None)
        if target is None or position is None:
            return HttpResponseRedirect('../../')

        try:
            page = self.model.objects.get(pk=page_id)
            target = self.model.objects.get(pk=target)
        except self.model.DoesNotExist:
            return HttpResponseBadRequest("error")

        # does he haves permissions to do this...?
        if not page.has_move_page_permission(request) or \
            not target.has_add_permission(request):
            return HttpResponseForbidden("Denied")

        # move page
        page.move_page(target, position)
        return render_admin_menu_item(request, page)