Пример #1
0
    def post(self, request, *args, **kwargs):
        comment_service_helper = get_comment_helper(self.get_object().service)

        comment_service_helper.load_comments(self.get_object())
        if self.get_object().status == 'open':
            if self.get_object().get_api_data()['state'] == 'closed':
                issue = self.get_object()
                issue.status = 'in review'
                issue.save()
        if self.request.POST.get('take'):
            if self.request.user.is_authenticated():
                taker = Taker(issue=self.get_object(), user=self.request.user)
                taker.save()
                issue = self.get_object()
                issue.status = "taken"
                issue.save()
            else:
                return redirect('/accounts/login/?next=/issue/' +
                                str(self.get_object().id))
        if self.request.POST.get('solution'):
            if self.request.user.is_authenticated():
                solution = Solution(issue=self.get_object(),
                                    user=self.request.user,
                                    url=request.POST.get('solution'))
                solution.save()
                action.send(self.request.user,
                            verb='posted ',
                            action_object=solution,
                            target=self.get_object())

            else:
                return redirect('/accounts/login/?next=/issue/' +
                                str(self.get_object().id))

        return super(IssueDetailView, self).get(request, *args, **kwargs)
Пример #2
0
def submit_issue_taker(data):
    issueID = data["issue"]
    user = data["user"]
    issuetakenTime = data["issueStartTime"]
    issueTaker = data["user"]
    issueEndtime = issuetakenTime + datetime.timedelta(hours=24)
    issue = Issue.objects.get(pk=issueID)
    taker = Taker(is_taken=True,issue=issue,user=user,status="taken",issueTaken=issuetakenTime,issueEnd=issueEndtime)
    taker.save()
    return data
Пример #3
0
def submit_issue_taker(data):
    issueID = data["issue"]
    user = data["user"]
    issuetakenTime = data["issueStartTime"]
    issueTaker = data["user"]
    issueEndtime = issuetakenTime + datetime.timedelta(hours=24)
    issue = Issue.objects.get(pk=issueID)
    issue.status = "taken"
    issue.save()
    taker = Taker(is_taken=True,issu_id=issueID,issue=issue,user=user,status="taken",issueTaken=issuetakenTime,issueEnd=issueEndtime)
    taker.save()
    return data
Пример #4
0
    def post(self, request, *args, **kwargs):
        comment_service_helper = get_comment_helper(self.get_object().service)

        comment_service_helper.load_comments(self.get_object())
        if self.get_object().status in ('open', 'in review'):
            if self.get_object().get_api_data()['state'] == 'closed':
                issue = self.get_object()
                if Solution.objects.filter(issue=issue):
                    # process the payment here and mark it as paid if the solution was accepted
                    issue.status = 'in review'
                else:
                    issue.status = 'closed'
                issue.save()
        if self.request.POST.get('take'):
            if self.request.user.is_authenticated():
                taker = Taker(issue=self.get_object(), user=self.request.user)
                taker.save()
                issue = self.get_object()
                issue.status = "taken"
                issue.save()
                #"yippie kay yay - someone took your coderbounty issue #1234 - they will have 4 hours before "
            else:
                return redirect('/accounts/login/?next=/issue/' +
                                str(self.get_object().id))
        if self.request.POST.get('solution'):
            if self.request.user.is_authenticated():
                solution = Solution(issue=self.get_object(),
                                    user=self.request.user,
                                    url=request.POST.get('solution'))
                solution.save()
                action.send(self.request.user,
                            verb='posted ',
                            action_object=solution,
                            target=self.get_object())

            else:
                return redirect('/accounts/login/?next=/issue/' +
                                str(self.get_object().id))

        return super(IssueDetailView, self).get(request, *args, **kwargs)
Пример #5
0
    def post(self, request, *args, **kwargs):
        comment_service_helper = get_comment_helper(self.get_object().service)

        comment_service_helper.load_comments(self.get_object())
        if self.get_object().status in ('open', 'in review'):
            if self.get_object().get_api_data()['state'] == 'closed':
                issue = self.get_object()
                if Solution.objects.filter(issue=issue):
                    # process the payment here and mark it as paid if the solution was accepted
                    issue.status = 'in review'
                else:
                    issue.status = 'closed'
                issue.save()
        if self.request.POST.get('take'):
            if self.request.user.is_authenticated():
                taker = Taker(issue=self.get_object(), user=self.request.user)
                taker.save()
                issue = self.get_object()
                issue.status = "taken"
                issue.save()
                #"yippie kay yay - someone took your coderbounty issue #1234 - they will have 4 hours before "
            else:
                return redirect('/accounts/login/?next=/issue/' + str(self.get_object().id))
        if self.request.POST.get('solution'):
            if self.request.user.is_authenticated():
                solution = Solution(
                    issue=self.get_object(),
                    user=self.request.user,
                    url=request.POST.get('solution'))
                solution.save()
                action.send(self.request.user, verb='posted ', action_object=solution, target=self.get_object())

            else:
                return redirect('/accounts/login/?next=/issue/' + str(self.get_object().id))

        return super(IssueDetailView, self).get(request, *args, **kwargs)
Пример #6
0
    def post(self, request, *args, **kwargs):
        comment_service_helper = get_comment_helper(self.get_object().service)

        comment_service_helper.load_comments(self.get_object())
        if self.get_object().status in ('open', 'in review'):
            if self.get_object().get_api_data()['state'] == 'closed':
                issue = self.get_object()
                if Solution.objects.filter(issue=issue):
                    # process the payment here and mark it as paid if the solution was accepted
                    issue.status = 'in review'
                else:
                    issue.status = 'closed'
                issue.save()
        if self.request.POST.get('take'):
            if self.request.user.is_authenticated():
                taker = Taker(issue=self.get_object(), user=self.request.user)
                taker.save()
                issue = self.get_object()
                issue.status = "taken"
                issue.save()
                action.send(self.request.user,
                            verb='has taken ',
                            target=self.get_object())
                msg_plain = render_to_string(
                    'email/issue_taken.txt', {
                        'user': self.request.user,
                        'issue': self.get_object(),
                        'time_remaining': taker.time_remaining
                    })
                msg_html = render_to_string(
                    'email/issue_taken.txt', {
                        'user': self.request.user,
                        'issue': self.get_object(),
                        'time_remaining': taker.time_remaining
                    })

                send_mail(
                    'You have taken issue: ' + self.get_object().project +
                    " issue #" + str(self.get_object().number),
                    msg_plain,
                    '*****@*****.**',
                    [self.request.user.email],
                    html_message=msg_html,
                )
            else:
                return redirect('/accounts/login/?next=/issue/' +
                                str(self.get_object().id))
        if self.request.POST.get('solution'):
            if self.get_object().status not in ('closed', 'in review'):

                if self.request.user.is_authenticated():
                    solution = Solution(issue=self.get_object(),
                                        user=self.request.user,
                                        url=request.POST.get('solution'))
                    solution.save()
                    issue = self.get_object()
                    issue.status = "in review"
                    issue.save()
                    action.send(self.request.user,
                                verb='posted ',
                                action_object=solution,
                                target=self.get_object())

                    bounty_poster = Bounty.objects.filter(
                        issue=self.get_object())[:1].get()

                    msg_plain = render_to_string('email/solution_posted.txt', {
                        'user': bounty_poster.user,
                        'issue': self.get_object()
                    })
                    msg_html = render_to_string('email/solution_posted.txt', {
                        'user': bounty_poster.user,
                        'issue': self.get_object()
                    })

                    send_mail(
                        'Coderbounty solution posted on ' +
                        self.get_object().project + " issue #" +
                        str(self.get_object().number),
                        msg_plain,
                        '*****@*****.**',
                        [bounty_poster.user.email],
                        html_message=msg_html,
                    )

                else:
                    return redirect('/accounts/login/?next=/issue/' +
                                    str(self.get_object().id))

        return super(IssueDetailView, self).get(request, *args, **kwargs)
Пример #7
0
    def post(self, request, *args, **kwargs):
        comment_service_helper = get_comment_helper(self.get_object().service)

        comment_service_helper.load_comments(self.get_object())
        if self.get_object().status in ("open", "in review"):
            if self.get_object().get_api_data()["state"] == "closed":
                issue = self.get_object()
                if Solution.objects.filter(issue=issue):
                    # process the payment here and mark it as paid if the solution was accepted
                    issue.status = "in review"
                else:
                    issue.status = "closed"
                issue.save()
        if self.request.POST.get("take"):
            if self.request.user.is_authenticated():
                taker = Taker(issue=self.get_object(), user=self.request.user)
                taker.save()
                issue = self.get_object()
                issue.status = "taken"
                issue.save()
                action.send(self.request.user, verb="has taken ", target=self.get_object())
                msg_plain = render_to_string(
                    "email/issue_taken.txt",
                    {"user": self.request.user, "issue": self.get_object(), "time_remaining": taker.time_remaining},
                )
                msg_html = render_to_string(
                    "email/issue_taken.txt",
                    {"user": self.request.user, "issue": self.get_object(), "time_remaining": taker.time_remaining},
                )

                send_mail(
                    "You have taken issue: " + self.get_object().project + " issue #" + str(self.get_object().number),
                    msg_plain,
                    "*****@*****.**",
                    [self.request.user.email],
                    html_message=msg_html,
                )
            else:
                return redirect("/accounts/login/?next=/issue/" + str(self.get_object().id))
        if self.request.POST.get("solution"):
            if self.get_object().status not in ("closed", "in review"):

                if self.request.user.is_authenticated():
                    solution = Solution(
                        issue=self.get_object(), user=self.request.user, url=request.POST.get("solution")
                    )
                    solution.save()
                    issue = self.get_object()
                    issue.status = "in review"
                    issue.save()
                    action.send(self.request.user, verb="posted ", action_object=solution, target=self.get_object())

                    bounty_poster = Bounty.objects.filter(issue=self.get_object())[:1].get()

                    msg_plain = render_to_string(
                        "email/solution_posted.txt", {"user": bounty_poster.user, "issue": self.get_object()}
                    )
                    msg_html = render_to_string(
                        "email/solution_posted.txt", {"user": bounty_poster.user, "issue": self.get_object()}
                    )

                    send_mail(
                        "Coderbounty solution posted on "
                        + self.get_object().project
                        + " issue #"
                        + str(self.get_object().number),
                        msg_plain,
                        "*****@*****.**",
                        [bounty_poster.user.email],
                        html_message=msg_html,
                    )

                else:
                    return redirect("/accounts/login/?next=/issue/" + str(self.get_object().id))

        return super(IssueDetailView, self).get(request, *args, **kwargs)