Exemple #1
0
class RejectBlog(TemplateView):
    template_name = "elect/reject_blog.html"

    def get(self, request, *args, **kwargs):
        self.blog = Blog.objects.get(pk=self.kwargs["pk"])
        return super(RejectBlog, self).get(request, *args, **kwargs)

    def get_context_data(self, **kwargs):
        from managers.forms import ModeratedForm

        context = super(RejectBlog, self).get_context_data(**kwargs)
        context["form"] = ModeratedForm()
        context["object"] = self.blog
        return context

    def post(self, request, *args, **kwargs):
        from managers.forms import ModeratedForm

        self.blog = Blog.objects.get(pk=self.kwargs["pk"])
        self.form_post = ModeratedForm(request.POST)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_blog_manager():
            post = self.form_post.save(commit=False)
            obj = post.get_or_create_moderated_object("BLO", self.blog.pk)
            obj.description = post.description
            obj.save(update_fields=["description"])
            self.blog.type = "REJ"
            self.blog.save(update_fields=["type"])
            return HttpResponse()
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
Exemple #2
0
 def post(self,request,*args,**kwargs):
     list = PhotoList.objects.get(uuid=self.kwargs["uuid"])
     form = ModeratedForm(request.POST)
     if form.is_valid() and request.user.is_photo_manager():
         mod = form.save(commit=False)
         moderate_obj = Moderated.get_or_create_moderated_object(object_id=list.pk, type="PHL")
         moderate_obj.create_close(object=list, description=mod.description, manager_id=request.user.pk)
         PhotoManageLog.objects.create(item=list.pk, manager=request.user.pk, action_type=PhotoManageLog.LIST_CLOSED)
         return HttpResponse()
     else:
         return HttpResponseBadRequest()
Exemple #3
0
    def post(self, request, *args, **kwargs):
        form, user = ModeratedForm(
            request.POST), User.objects.get(pk=self.kwargs["pk"])

        if request.is_ajax() and form.is_valid(
        ) and request.user.is_user_manager():
            from django.utils import timezone

            mod = form.save(commit=False)
            number = request.POST.get('number')
            moderate_obj = Moderated.get_or_create_moderated_object(
                object_id=user.pk, type="USE")
            moderate_obj.status = Moderated.SUSPEND
            moderate_obj.description = mod.description
            moderate_obj.save()
            if number == '4':
                duration_of_penalty = timezone.now() + timezone.timedelta(
                    days=30)
                UserManageLog.objects.create(
                    user=user.pk,
                    manager=request.user.pk,
                    action_type=UserManageLog.SEVERITY_CRITICAL)
            elif number == '3':
                duration_of_penalty = timezone.now() + timezone.timedelta(
                    days=7)
                UserManageLog.objects.create(
                    user=user.pk,
                    manager=request.user.pk,
                    action_type=UserManageLog.SEVERITY_HIGH)
            elif number == '2':
                duration_of_penalty = timezone.now() + timezone.timedelta(
                    days=3)
                UserManageLog.objects.create(
                    user=user.pk,
                    manager=request.user.pk,
                    action_type=UserManageLog.SEVERITY_MEDIUM)
            elif number == '1':
                duration_of_penalty = timezone.now() + timezone.timedelta(
                    hours=6)
                UserManageLog.objects.create(
                    user=user.pk,
                    manager=request.user.pk,
                    action_type=UserManageLog.SEVERITY_LOW)
            moderate_obj.create_suspend(
                manager_id=request.user.pk,
                duration_of_penalty=duration_of_penalty)
            user.suspend_item()
            return HttpResponse()
        else:
            return HttpResponseBadRequest()
Exemple #4
0
 def post(self, request, *args, **kwargs):
     comment = ElectNewComment.objects.get(pk=self.kwargs["pk"])
     form = ModeratedForm(request.POST)
     if form.is_valid() and request.user.is_elect_new_manager():
         mod = form.save(commit=False)
         moderate_obj = Moderated.get_or_create_moderated_object(
             object_id=comment.pk, type="ELEC")
         moderate_obj.create_close(object=comment,
                                   description=mod.description,
                                   manager_id=request.user.pk)
         ElectNewManageLog.objects.create(
             item=comment.pk,
             manager=request.user.pk,
             action_type=ElectNewManageLog.COMMENT_CLOSED)
         return HttpResponse()
     else:
         return HttpResponseBadRequest()
Exemple #5
0
    def post(self, request, *args, **kwargs):
        from django.utils import timezone

        form = ModeratedForm(request.POST)

        if request.is_ajax() and form.is_valid(
        ) and request.user.is_community_manager():
            mod = form.save(commit=False)
            number = request.POST.get('number')
            moderate_obj = Moderated.get_or_create_moderated_object(
                object_id=self.kwargs["pk"], type="COM")
            moderate_obj.status = Moderated.SUSPEND
            moderate_obj.description = mod.description
            moderate_obj.type = ""
            moderate_obj.save()
            if severity_int == '4':
                duration_of_penalty = timezone.timedelta(days=30)
                CommunityManageLog.objects.create(
                    item=self.pk,
                    manager=request.user.pk,
                    action_type=CommunityManageLog.SEVERITY_CRITICAL)
            elif severity_int == '3':
                duration_of_penalty = timezone.timedelta(days=7)
                CommunityManageLog.objects.create(
                    item=self.pk,
                    manager=request.user.pk,
                    action_type=CommunityManageLog.SEVERITY_HIGH)
            elif severity_int == '2':
                duration_of_penalty = timezone.timedelta(days=3)
                CommunityManageLog.objects.create(
                    item=self.pk,
                    manager=request.user.pk,
                    action_type=CommunityManageLog.SEVERITY_MEDIUM)
            elif severity_int == '1':
                duration_of_penalty = timezone.timedelta(hours=6)
                CommunityManageLog.objects.create(
                    item=self.pk,
                    manager=request.user.pk,
                    action_type=CommunityManageLog.SEVERITY_LOW)
            moderate_obj.create_suspend(
                manager_id=request.user.pk,
                duration_of_penalty=duration_of_penalty)
            return HttpResponse()
        else:
            return HttpResponseBadRequest()
Exemple #6
0
 def post(self, request, *args, **kwargs):
     form = ModeratedForm(request.POST)
     if request.is_ajax() and form.is_valid(
     ) and request.user.is_community_manager():
         mod = form.save(commit=False)
         moderate_obj = Moderated.get_or_create_moderated_object(
             type="COM", object_id=self.kwargs["pk"])
         moderate_obj.status = Moderated.BANNER_GET
         moderate_obj.description = mod.description
         moderate_obj.save()
         moderate_obj.create_warning_banner(manager_id=request.user.pk)
         CommunityManageLog.objects.create(
             item=self.kwargs["pk"],
             manager=request.user.pk,
             action_type=CommunityManageLog.WARNING_BANNER)
         return HttpResponse()
     else:
         return HttpResponseBadRequest()
Exemple #7
0
 def post(self, request, *args, **kwargs):
     community = Community.objects.get(pk=self.kwargs["pk"])
     form = ModeratedForm(request.POST)
     if request.is_ajax() and form.is_valid(
     ) and request.user.is_community_manager():
         mod = form.save(commit=False)
         moderate_obj = Moderated.get_or_create_moderated_object(
             type="COM", object_id=community.pk)
         moderate_obj.create_close(object=community,
                                   description=mod.description,
                                   manager_id=request.user.pk)
         CommunityManageLog.objects.create(
             item=self.kwargs["pk"],
             manager=request.user.pk,
             action_type=CommunityManageLog.ITEM_CLOSED)
         return HttpResponse()
     else:
         return HttpResponseBadRequest()
Exemple #8
0
class RejectCommunity(View):
    def get(self, request, *args, **kwargs):
        from managers.forms import ModeratedForm

        self.community = Community.objects.get(pk=self.kwargs["pk"])
        self.form_post = ModeratedForm(request.POST)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_community_manager():
            post = self.form_post.save(commit=False)
            obj = post.get_or_create_moderated_object("COM", self.community.pk)
            obj.description = post.description
            obj.save(update_fields=["description"])
            self.community.perm = "_RE"
            self.community.save(update_fields=["perm"])
            return HttpResponse()
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
Exemple #9
0
class RejectOrganization(View):
    def get(self, request, *args, **kwargs):
        from managers.forms import ModeratedForm

        self.organization = Organization.objects.get(pk=self.kwargs["pk"])
        self.form_post = ModeratedForm(request.POST)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_organization_manager():
            post = self.form_post.save(commit=False)
            obj = post.get_or_create_moderated_object("ORG",
                                                      self.organization.pk)
            obj.description = post.description
            obj.save(update_fields=["description"])
            self.organization.type = "_REJ"
            self.organization.save(update_fields=["type"])
            return HttpResponse()
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
Exemple #10
0
class RejectElectNew(View):
    def get(self, request, *args, **kwargs):
        from managers.forms import ModeratedForm

        self.elect_new = ElectNew.objects.get(pk=self.kwargs["pk"])
        self.form_post = ModeratedForm(request.POST)

        if request.is_ajax() and self.form_post.is_valid(
        ) and request.user.is_elect_new_manager():
            post = self.form_post.save(commit=False)
            obj = post.get_or_create_moderated_object("ELE", self.elect_new.pk)
            obj.description = post.description
            obj.status = "SR"
            obj.save(update_fields=["description", "status"])
            self.elect_new.type = "_REJ"
            self.elect_new.save(update_fields=["type"])
            ElectNewManageLog.objects.create(
                item=post.pk,
                manager=request.user.pk,
                action_type=ElectNewManageLog.SUGGEST_ITEM_REJECT)
            return HttpResponse()
        else:
            from django.http import HttpResponseBadRequest
            return HttpResponseBadRequest()
Exemple #11
0
    def post(self, request, *args, **kwargs):
        from django.http import HttpResponse, HttpResponseBadRequest
        from managers.models import Moderated, ModeratedLogs
        from common.utils import get_item_for_post_sanction
        from managers.forms import ModeratedForm

        type = request.POST.get('_type')
        subtype = request.POST.get('_subtype')

        list = get_item_for_post_sanction(type, subtype)
        if (list[2] and request.user.is_administrator()
            ) or not request.user.is_moderator():
            return HttpResponseBadRequest()

        form = ModeratedForm(request.POST)
        if request.is_ajax() and form.is_valid():
            mod = form.save(commit=False)
            case = request.POST.get('case')
            item = list[0]
            moderate_obj = Moderated.get_or_create_moderated_object(
                object_id=item.pk, type=list[1])
            if case == "close":
                moderate_obj.create_close(object=item,
                                          description=mod.description,
                                          manager_id=request.user.pk)
                ModeratedLogs.objects.create(type=list[1],
                                             object_id=item.pk,
                                             manager=request.user.pk,
                                             action=list[3][0])
                item.close_item()

            elif case == "suspend":
                from django.utils import timezone
                from common.tasks import abort_suspended
                from datetime import datetime, timedelta

                moderate_obj.status = Moderated.SUSPEND
                moderate_obj.description = mod.description
                moderate_obj.save()
                number = request.POST.get('number')
                if number == '4':
                    duration_of_penalty = timezone.now() + timezone.timedelta(
                        days=30)
                elif number == '3':
                    duration_of_penalty = timezone.now() + timezone.timedelta(
                        days=7)
                elif number == '2':
                    duration_of_penalty = timezone.now() + timezone.timedelta(
                        days=3)
                elif number == '1':
                    duration_of_penalty = timezone.now() + timezone.timedelta(
                        hours=6)

                moderate_obj.create_suspend(
                    manager_id=request.user.pk,
                    duration_of_penalty=duration_of_penalty)
                ModeratedLogs.objects.create(type=list[1],
                                             object_id=item.pk,
                                             manager=request.user.pk,
                                             action=list[3][1])
                item.suspend_item()
                abort_suspended.apply_async(args=(list[1], ),
                                            eta=duration_of_penalty)
            elif case == "warning_banner":
                moderate_obj.status = Moderated.BANNER_GET
                moderate_obj.description = mod.description
                moderate_obj.save()
                moderate_obj.create_warning_banner(manager_id=request.user.pk)
                ModeratedLogs.objects.create(type=list[1],
                                             object_id=item.pk,
                                             manager=request.user.pk,
                                             action=31)
                item.banner_item()
            return HttpResponse()
        else:
            return HttpResponseBadRequest()