Exemple #1
0
    def form_valid(self, form):

        action = self.get_object()
        self.request.user.assert_can_create_blog_post(action)
        action.blog_post_add(form.cleaned_data['title'],
                             form.cleaned_data['text'], self.request.user)
        return views_support.response_success(self.request)
Exemple #2
0
    def post(self, request, *args, **kwargs):

        action = self.get_object()
        user = request.user
        user.assert_can_unfollow_action(action)
        user.unfollow_action(action)

        return views_support.response_success(request)
Exemple #3
0
    def post(self, request, *args, **kwargs):

        action = self.get_object()
        user = request.user
        user.assert_can_unfollow_action(action)
        user.unfollow_action(action)
        
        return views_support.response_success(request)
Exemple #4
0
 def form_valid(self, form):
     """ Redirect to get_success_url(). Must return an HttpResponse."""
     post = self.get_object()
     #WAS: post.comment_add(form.cleaned_data['text'], self.request.user)
     post.add_comment(form.cleaned_data['text'],
                      self.request.user,
                      added_at=None,
                      by_email=False)
     return views_support.response_success(self.request)
Exemple #5
0
    def form_valid(self, form):

        action = self.get_object()
        self.request.user.assert_can_create_blog_post(action)
        action.blog_post_add(
            form.cleaned_data['title'], 
            form.cleaned_data['text'], self.request.user
        )
        return views_support.response_success(self.request)
Exemple #6
0
 def form_valid(self, form):
     """ Redirect to get_success_url(). Must return an HttpResponse."""
     post = self.get_object()
     #WAS: post.comment_add(form.cleaned_data['text'], self.request.user)
     post.add_comment(form.cleaned_data['text'], 
         self.request.user,
         added_at=None, 
         by_email=False
     )
     return views_support.response_success(self.request)
Exemple #7
0
    def post(self, request, *args, **kwargs):
        action = self.get_object()
        request.user.assert_can_vote_action(action)

        referral = self.get_referral(action)
        # Check referral
        if referral:
            if referral == request.user:
                # QUESTION TO ASK: what if a user design itself as a referral
                # for its vote? Should the vote be valid or not? Or, should
                # be the user (and the Action referrers) be notified of this?
                log.debug("User %s has itself as the referral for its vote \
                     on the action %s" % (request.user, action))
        action.vote_add(request.user, referral=referral)

        return views_support.response_success(request)
Exemple #8
0
    def post(self, request, *args, **kwargs):
        action = self.get_object()
        request.user.assert_can_vote_action(action)

        referral = self.get_referral(action)
        # Check referral
        if referral:
            if referral == request.user:
                # QUESTION TO ASK: what if a user design itself as a referral
                # for its vote? Should the vote be valid or not? Or, should
                # be the user (and the Action referrers) be notified of this?
                log.debug("User %s has itself as the referral for its vote \
                     on the action %s" % (request.user, action))
        action.vote_add(request.user, referral=referral)
        
        return views_support.response_success(request)
Exemple #9
0
    def post(self, request, *args, **kwargs):
        org = self.get_object()
        user = request.user

        mapping, created = UserOrgMap.objects.get_or_create(user=user,
            org=org,
        )
        if mapping.is_representative:
            raise exceptions.UserCannotRepresentOrgTwice(user, org) 
        else:
            mapping.is_representative=True
            mapping.save()

        # QUESTION: should we notify (here or in an UserOrgMap post_save
        # signal) to the Organization that a new User is following them ?
        
        return views_support.response_success(request)
Exemple #10
0
    def post(self, request, *args, **kwargs):
        org = self.get_object()
        user = request.user

        mapping, created = UserOrgMap.objects.get_or_create(
            user=user,
            org=org,
        )
        if mapping.is_representative:
            raise exceptions.UserCannotRepresentOrgTwice(user, org)
        else:
            mapping.is_representative = True
            mapping.save()

        # QUESTION: should we notify (here or in an UserOrgMap post_save
        # signal) to the Organization that a new User is following them ?

        return views_support.response_success(request)
Exemple #11
0
 def form_valid(self, form):
     """ Redirect to get_success_url(). Must return an HttpResponse."""
     action = self.get_object()
     #WAS: return action.comment_add(form.cleaned_data['text'], self.request.user)
     action.comment_add(form.cleaned_data['text'], self.request.user)
     return views_support.response_success(self.request)
Exemple #12
0
 def post(self, request, *args, **kwargs):
     comment = self.get_object()
     request.user.assert_can_vote_comment(comment)
     referral = self.get_referral(comment.action)
     askbot_extensions_utils.vote_add(comment, request.user, referral)
     return views_support.response_success(request)
Exemple #13
0
 def form_valid(self, form):
     """ Redirect to get_success_url(). Must return an HttpResponse."""
     action = self.get_object()
     #WAS: return action.comment_add(form.cleaned_data['text'], self.request.user)
     action.comment_add(form.cleaned_data['text'], self.request.user)
     return views_support.response_success(self.request)
Exemple #14
0
 def post(self, request, *args, **kwargs):
     comment = self.get_object()
     request.user.assert_can_vote_comment(comment)
     referral = self.get_referral(comment.action)
     askbot_extensions_utils.vote_add(comment, request.user, referral)
     return views_support.response_success(request)