Esempio n. 1
0
 def get_context_data(self, **kwargs):
     context = super(IssueDetailView, self).get_context_data(**kwargs)
     context['leaderboard'] = leaderboard()
     context['taker'] = self.get_object().get_taker()
     context['takers'] = Taker.objects.filter(
         issue=self.get_object()).order_by('-created')
     context['solutions'] = Solution.objects.filter(
         issue=self.get_object()).order_by('-created')
     # comment_set = context['object'].comment_set.all()
     # context['object'] = context['object'].__dict__
     # context['object']['comment_set'] = []
     # for comment in comment_set:
     #     comment = comment.__dict__
     #     try:
     #         comment_user = User.objects.get(username=comment['username'])
     #         comment['useravatar'] = UserProfile.objects.get(user=comment_user).avatar()
     #     except User.DoesNotExist, UserProfile.DoesNotExist:
     #         # github usernames are different from the coderbounty usernames.
     #         # Then, show default useravatar.
     #         comment['useravatar'] = static('images/temp/thumb-medium-00.jpg')
     #     context['object']['comment_set'].append(comment)
     if not context['taker'] and self.get_object().status == "taken":
         issue = self.get_object()
         issue.status = "open"
         issue.save()
     return context
Esempio n. 2
0
def home(request, template="index.html"):
    activities = Action.objects.all()[0:10]
    context = {
        'activities': activities,
        'leaderboard': leaderboard(),
    }
    response = render_to_response(template, context, context_instance=RequestContext(request))
    return response
Esempio n. 3
0
def home(request, template="index.html"):
    activities = Action.objects.all()[0:10]
    context = {
        'activities': activities,
        'leaderboard': leaderboard(),
    }
    response = render_to_response(template, context, context_instance=RequestContext(request))
    return response
Esempio n. 4
0
 def get_context_data(self, **kwargs):
     context = super(IssueDetailView, self).get_context_data(**kwargs)
     context['leaderboard'] = leaderboard()
     context['taker'] = self.get_object().get_taker()
     context['takers'] = Taker.objects.filter(issue=self.get_object()).order_by('-created')
     context['solutions'] = Solution.objects.filter(issue=self.get_object()).order_by('-created')
     if not context['taker'] and self.get_object().status == "taken":
         issue = self.get_object()
         issue.status = "open"
         issue.save()
     return context
Esempio n. 5
0
 def get_context_data(self, **kwargs):
     context = super(IssueDetailView, self).get_context_data(**kwargs)
     context["leaderboard"] = leaderboard()
     context["taker"] = self.get_object().get_taker()
     context["takers"] = Taker.objects.filter(issue=self.get_object()).order_by("-created")
     context["solutions"] = Solution.objects.filter(issue=self.get_object()).order_by("-created")
     if not context["taker"] and self.get_object().status == "taken":
         issue = self.get_object()
         issue.status = "open"
         issue.save()
     return context
Esempio n. 6
0
    def get_context_data(self, **kwargs):
        context = super(LeaderboardView, self).get_context_data(**kwargs)
        leaderboard_users = User.objects.all().annotate(
            null_position=Count('userprofile__balance')).order_by(
                '-null_position', '-userprofile__balance', '-last_login')
        paginator = Paginator(leaderboard_users, self.paginate_by)
        page = self.request.GET.get('page')

        try:
            leaderboard_users_paginated = paginator.page(page)
        except PageNotAnInteger:
            leaderboard_users_paginated = paginator.page(1)
        except EmptyPage:
            leaderboard_users_paginated = paginator.page(paginator.num_pages)

        context['leaderboard'] = leaderboard()
        context['object_list'] = leaderboard_users_paginated
        return context
Esempio n. 7
0
    def get_context_data(self, **kwargs):
        context = super(LeaderboardView, self).get_context_data(**kwargs)
        leaderboard_users = User.objects.filter(
            payment__amount__gt=0).annotate(
                total=Sum('payment__amount')).order_by('-total')
        paginator = Paginator(leaderboard_users, self.paginate_by)
        page = self.request.GET.get('page')

        try:
            leaderboard_users_paginated = paginator.page(page)
        except PageNotAnInteger:
            leaderboard_users_paginated = paginator.page(1)
        except EmptyPage:
            leaderboard_users_paginated = paginator.page(paginator.num_pages)

        context['leaderboard'] = leaderboard()
        context['object_list'] = leaderboard_users_paginated
        return context
Esempio n. 8
0
    def get_context_data(self, **kwargs):
        context = super(LeaderboardView, self).get_context_data(**kwargs)
        leaderboard_users = (
            User.objects.all()
            .annotate(null_position=Count("userprofile__balance"))
            .order_by("-null_position", "-userprofile__balance", "-last_login")
        )
        paginator = Paginator(leaderboard_users, self.paginate_by)
        page = self.request.GET.get("page")

        try:
            leaderboard_users_paginated = paginator.page(page)
        except PageNotAnInteger:
            leaderboard_users_paginated = paginator.page(1)
        except EmptyPage:
            leaderboard_users_paginated = paginator.page(paginator.num_pages)

        context["leaderboard"] = leaderboard()
        context["object_list"] = leaderboard_users_paginated
        return context
Esempio n. 9
0
 def get_context_data(self, **kwargs):
     context = super(LeaderboardView, self).get_context_data(**kwargs)
     context['leaderboard'] = leaderboard()
     return context
Esempio n. 10
0
def home(request, template="index.html", page_template="issues.html"):

    ## print request.session.get('coin_count')
    ## print request.session.get('coin_dates')

    ## day_of_year = datetime.datetime.strftime(datetime.datetime.now(), "%j")
    ## if "coin_dates" in request.session:
    ## coin_dates = request.session.get('coin_dates')
    ## if not day_of_year in coin_dates:
    ## coin_count =  request.session.get('coin_count')
    ## request.session['coin_count']=coin_count+1
    ## request.session['coin_dates'].append(day_of_year)
    ## else:
    ## request.session['coin_count']=1
    ## request.session['coin_dates']=[day_of_year,]

    # if request.GET.get('checkout_id') and request.session.get('issue'):

    #     wepay = WePay(production=settings.IN_PRODUCTION, access_token=settings.WEPAY_ACCESS_TOKEN)
    #     ctx = {
    #         'checkout_id': request.GET.get('checkout_id'),
    #         }
    #     wepay_call_return = wepay.call('/checkout', ctx)
    #     if wepay_call_return['state'] == "authorized":
    #         request.session['issue']['bounty'] = wepay_call_return['amount']
    #         message = "$" + str(request.session['issue']['bounty']) + " bounty added to " +\
    #         request.session['issue']['project'] + " issue #" + str(request.session['issue']['number'])
    #         if add_issue_to_database(request):
    #             messages.add_message(request, messages.SUCCESS, message)

    status = request.GET.get('status', 'open')
    order = request.GET.get('order', '-bounty')
    q = request.GET.get('q', '')

    issues = get_issues(q, status, order)

    activities = Action.objects.all()[0:10]

    if request.is_ajax():
        template = page_template

    context = {
        'activities': activities,
        'issues': issues,
        'issue_counts': issue_counts(),
        'page_template': page_template,
        'q': q,
        'leaderboard': leaderboard(),
        'wepay_host': settings.DEBUG and "stage" or "www",
        'status': status,
        #'form': UserCreationForm()
    }

    day_of_year = datetime.datetime.strftime(datetime.datetime.now(), "%j")
    ## day_of_year = str(int(day_of_year) + 2)
    # if request.user.is_authenticated():
    #     if Coin.objects.add_coin_for_user(request.user, request):
    #         context.update({'coin_added': 1})
    #     response = render_to_response(template, context, context_instance=RequestContext(request))
    # else:
    #     try:
    #         coins_count = int(request.COOKIES.get('coins', 0))
    #     except ValueError:
    #         coins_count = 0
    #     if day_of_year != request.COOKIES.get('day'):
    #         coins_count += 1
    #         context.update({'coin_added': 1})
    #         response = render_to_response(template, context, context_instance=RequestContext(request))
    #         response.set_cookie('day', day_of_year, max_age=3600 * 24)
    #         response.set_cookie('coins', coins_count, max_age=3600 * 24 * 365 * 5)
    #     elif coins_count == 0:
    #         coins_count += 1
    #         context.update({'coin_added': 1})
    #         response = render_to_response(template, context, context_instance=RequestContext(request))
    #         response.set_cookie('coins', coins_count, max_age=3600 * 24 * 365 * 5)
    #     else:
    #
    response = render_to_response(template,
                                  context,
                                  context_instance=RequestContext(request))
    return response
Esempio n. 11
0
 def get_context_data(self, **kwargs):
     context = super(IssueDetailView, self).get_context_data(**kwargs)
     context['leaderboard'] = leaderboard()        
     return context
Esempio n. 12
0
def home(request,
    template="index.html",
    page_template="issues.html"):

    ## print request.session.get('coin_count')
    ## print request.session.get('coin_dates')

    ## day_of_year = datetime.datetime.strftime(datetime.datetime.now(), "%j")
    ## if "coin_dates" in request.session:
        ## coin_dates = request.session.get('coin_dates')
        ## if not day_of_year in coin_dates:
            ## coin_count =  request.session.get('coin_count')
            ## request.session['coin_count']=coin_count+1
            ## request.session['coin_dates'].append(day_of_year)
    ## else:
        ## request.session['coin_count']=1
        ## request.session['coin_dates']=[day_of_year,]

    # if request.GET.get('checkout_id') and request.session.get('issue'):

    #     wepay = WePay(production=settings.IN_PRODUCTION, access_token=settings.WEPAY_ACCESS_TOKEN)
    #     ctx = {
    #         'checkout_id': request.GET.get('checkout_id'),
    #         }
    #     wepay_call_return = wepay.call('/checkout', ctx)
    #     if wepay_call_return['state'] == "authorized":
    #         request.session['issue']['bounty'] = wepay_call_return['amount']
    #         message = "$" + str(request.session['issue']['bounty']) + " bounty added to " +\
    #         request.session['issue']['project'] + " issue #" + str(request.session['issue']['number'])
    #         if add_issue_to_database(request):
    #             messages.add_message(request, messages.SUCCESS, message)

    status = request.GET.get('status', 'open')
    order = request.GET.get('order', '-bounty')
    q = request.GET.get('q', '')

    issues = get_issues(q, status, order)

    if request.is_ajax():
        template = page_template

    context = {
        'issues': issues,
        'issue_counts': issue_counts(),
        'page_template': page_template,
        'q': q,
        'leaderboard': leaderboard(),
        'wepay_host': settings.DEBUG and "stage" or "www",
        'status': status,
        #'form': UserCreationForm()
    }

    day_of_year = datetime.datetime.strftime(datetime.datetime.now(), "%j")
    ## day_of_year = str(int(day_of_year) + 2)
    # if request.user.is_authenticated():
    #     if Coin.objects.add_coin_for_user(request.user, request):
    #         context.update({'coin_added': 1})
    #     response = render_to_response(template, context, context_instance=RequestContext(request))
    # else:
    #     try:
    #         coins_count = int(request.COOKIES.get('coins', 0))
    #     except ValueError:
    #         coins_count = 0
    #     if day_of_year != request.COOKIES.get('day'):
    #         coins_count += 1
    #         context.update({'coin_added': 1})
    #         response = render_to_response(template, context, context_instance=RequestContext(request))
    #         response.set_cookie('day', day_of_year, max_age=3600 * 24)
    #         response.set_cookie('coins', coins_count, max_age=3600 * 24 * 365 * 5)
    #     elif coins_count == 0:
    #         coins_count += 1
    #         context.update({'coin_added': 1})
    #         response = render_to_response(template, context, context_instance=RequestContext(request))
    #         response.set_cookie('coins', coins_count, max_age=3600 * 24 * 365 * 5)
    #     else:
    #         
    response = render_to_response(template, context, context_instance=RequestContext(request))
    return response