示例#1
0
    def post(self,request,*args,**kwargs):
        from common.check.community import check_private_post_exists

        form_post = PostForm(request.POST)
        list = PostsList.objects.get(pk=self.kwargs["pk"])
        community = list.community

        check_private_post_exists(community)
        if request.is_ajax() and form_post.is_valid():
            check_can_get_lists(request.user, community)
            post = form_post.save(commit=False)
            new_post = post.create_creator_offer_post(
                                        creator=request.user,
                                        attach=request.POST.getlist('attach_items'),
                                        text=post.text,
                                        category=post.category,
                                        list=list,
                                        comments_enabled=post.comments_enabled,
                                        is_signature=post.is_signature,
                                        votes_on=post.votes_on,
                                        community=community
                                        )
            return HttpResponse()
        else:
            return HttpResponseBadRequest()
示例#2
0
    def post(self,request,*args,**kwargs):
        from common.check.community import check_private_post_exists

        form_post = PostForm(request.POST)
        list = PostsList.objects.get(pk=self.kwargs["pk"])
        community = list.community
        check_private_post_exists(community)

        if community.is_wall_close():
            raise Http404
        elif community.is_staff_post_member_can() and not request.user.is_member_of_community(community.pk):
            raise Http404
        elif request.is_ajax() and form_post.is_valid():
            check_can_get_lists(request.user, community)
            post = form_post.save(commit=False)
            if request.POST.get('text') or request.POST.getlist('attach_items'):
                from common.notify.notify import community_notify
                from common.processing.post import get_post_offer_processing
                from common.templates import render_for_platform

                lists, attach = request.POST.getlist("lists"), request.POST.getlist('attach_items')
                new_post = post.create_offer_post(
                                            creator=request.user,
                                            attach=attach,
                                            text=post.text,
                                            list=list,
                                            community=community)
                return render_for_platform(request, 'posts/post_community/post.html', {'object': new_post})
            else:
                return HttpResponseBadRequest()
        else:
            return HttpResponseBadRequest()
示例#3
0
 def get(self, request, *args, **kwargs):
     list = SurveyList.objects.get(uuid=self.kwargs["uuid"])
     check_can_get_lists(request.user, list.community)
     if request.is_ajax() and list.is_user_can_delete_list(request.user.pk):
         list.communties.remove(request.user)
     return HttpResponse()
示例#4
0
 def get(self, request, **kwargs):
     answer = Answer.objects.get(pk=self.kwargs["survey_pk"])
     community = Community.objects.get(pk=self.kwargs["pk"])
     check_can_get_lists(request.user, community)
     return answer.vote(request.user, community)