当前位置: 首页>>代码示例>>Python>>正文


Python viewutil.get_event函数代码示例

本文整理汇总了Python中tracker.viewutil.get_event函数的典型用法代码示例。如果您正苦于以下问题:Python get_event函数的具体用法?Python get_event怎么用?Python get_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: donationindex

def donationindex(request, event=None):
    event = viewutil.get_event(event)
    orderdict = {
        'amount': ('amount', ),
        'time': ('timereceived', ),
    }
    page = request.GET.get('page', 1)
    sort = request.GET.get('sort', 'time')

    try:
        order = int(request.GET.get('order', -1))
    except ValueError:
        order = -1

    donations = Donation.objects.filter(transactionstate='COMPLETED')

    if event.id:
        donations = donations.filter(event=event)
    donations = views_common.fixorder(donations, orderdict, sort, order)

    agg = donations.aggregate(amount=Sum('amount'), count=Count(
        'amount'), max=Max('amount'), avg=Avg('amount'))
    donations = donations.select_related('donor')
    pages = paginator.Paginator(donations, 50)
    try:
        pageinfo = pages.page(page)
    except paginator.PageNotAnInteger:
        pageinfo = pages.page(1)
    except paginator.EmptyPage:
        pageinfo = pages.page(pages.num_pages)
        page = pages.num_pages
    donations = pageinfo.object_list

    return views_common.tracker_response(request, 'tracker/donationindex.html', {'donations': donations, 'pageinfo':  pageinfo, 'page': page, 'agg': agg, 'sort': sort, 'order': order, 'event': event})
开发者ID:TipoftheHats,项目名称:donation-tracker,代码行数:34,代码来源:public.py

示例2: password_reset

def password_reset(request):
  return auth_views.password_reset(request, 
    template_name='tracker/password_reset.html', 
    email_template_name='password_reset_template',
    password_reset_form=PostOfficePasswordResetForm,
    from_email=settings.EMAIL_FROM_USER, 
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
开发者ID:quinox,项目名称:sda-donation-tracker-2,代码行数:7,代码来源:views.py

示例3: donate

def donate(request, event):
    event = viewutil.get_event(event)
    if event.locked:
        raise Http404
    commentform, bidsform, prizesform = process_form(request, event)
    if not bidsform:  # redirect
        return commentform

    def bid_parent_info(bid):
        if bid != None:
            return {'name': bid.name, 'description': bid.description, 'parent': bid_parent_info(bid.parent)}
        else:
            return None

    def bid_info(bid):
        result = {
            'id': bid.id,
            'name': bid.name,
            'description': bid.description,
            'label': bid.full_label(not bid.allowuseroptions),
            'count': bid.count,
            'amount': bid.total,
            'goal': Decimal(bid.goal or '0.00'),
            'parent': bid_parent_info(bid.parent)
        }
        if bid.speedrun:
            result['runname'] = bid.speedrun.name
        if bid.suggestions.exists():
            result['suggested'] = list(
                map(lambda x: x.name, bid.suggestions.all()))
        if bid.allowuseroptions:
            result['custom'] = ['custom']
            result['label'] += ' (select and add a name next to "New Option Name")'
        return result

    bids = filters.run_model_query('bidtarget', {'state': 'OPENED', 'event': event.id}, user=request.user).distinct(
    ).select_related('parent').prefetch_related('suggestions')

    allPrizes = filters.run_model_query(
        'prize', {'feed': 'current', 'event': event.id})

    prizes = allPrizes.filter(ticketdraw=False)

    dumpArray = [bid_info(o) for o in bids]

    bidsJson = json.dumps(dumpArray, ensure_ascii=False,
                          cls=serializers.json.DjangoJSONEncoder)

    ticketPrizes = allPrizes.filter(ticketdraw=True)

    def prize_info(prize):
        result = {'id': prize.id, 'name': prize.name, 'description': prize.description,
                  'minimumbid': prize.minimumbid, 'maximumbid': prize.maximumbid, 'sumdonations': prize.sumdonations}
        return result

    dumpArray = [prize_info(o) for o in ticketPrizes.all()]
    ticketPrizesJson = json.dumps(
        dumpArray, ensure_ascii=False, cls=serializers.json.DjangoJSONEncoder)

    return views_common.tracker_response(request, "tracker/donate.html", {'event': event, 'bidsform': bidsform, 'prizesform': prizesform, 'commentform': commentform, 'hasBids': bids.count() > 0, 'bidsJson': bidsJson, 'hasTicketPrizes': ticketPrizes.count() > 0, 'ticketPrizesJson': ticketPrizesJson, 'prizes': prizes})
开发者ID:TipoftheHats,项目名称:donation-tracker,代码行数:60,代码来源:donateviews.py

示例4: tracker_response

def tracker_response(request=None, template='tracker/index.html', qdict=None, status=200):
  starttime = datetime.datetime.now()
  language = translation.get_language_from_request(request)
  translation.activate(language)
  request.LANGUAGE_CODE = translation.get_language()
  profile = None
  qdict = qdict or {}
  qdict.update({
    'djangoversion' : dv(),
    'pythonversion' : pv(),
    'user' : request.user,
    'profile' : profile,
    'next' : request.POST.get('next', request.GET.get('next', request.path)),
    'starttime' : starttime,
    'events': tracker.models.Event.objects.all(),
    })
  qdict.setdefault('event',viewutil.get_event(None))
  try:
    resp = render(request, template, dictionary=qdict, status=status)
    if 'queries' in request.GET and request.user.has_perm('tracker.view_queries'):
      return HttpResponse(json.dumps(connection.queries, ensure_ascii=False, indent=1),content_type='application/json;charset=utf-8')
    return resp
  except Exception,e:
    if request.user.is_staff and not settings.DEBUG:
      return HttpResponse(unicode(type(e)) + '\n\n' + unicode(e), mimetype='text/plain', status=500)
    raise
开发者ID:uraniumanchor,项目名称:sda-donation-tracker-2-read-only,代码行数:26,代码来源:common.py

示例5: password_reset

def password_reset(request):
  return djauth_views.password_reset(request,
    template_name='tracker/password_reset.html',
    email_template_name='password_reset_template',
    password_reset_form=forms.PostOfficePasswordResetForm,
    from_email=viewutil.get_default_email_from_user(),
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
开发者ID:uraniumanchor,项目名称:sda-donation-tracker-2-read-only,代码行数:7,代码来源:auth.py

示例6: bidindex

def bidindex(request, event=None):
  event = viewutil.get_event(event)
  searchForm = BidSearchForm(request.GET)
  
  if not searchForm.is_valid():
    return HttpResponse('Invalid filter form', status=400)
    
  searchParams = {}
  searchParams.update(request.GET)
  searchParams.update(searchForm.cleaned_data)
  
  if event.id:
    searchParams['event'] = event.id
  else:
    return HttpResponseRedirect(reverse('tracker.views.bidindex', args=(Event.objects.latest().id,)))
    
  bids = filters.run_model_query('bid', searchParams, user=request.user)
  bids = bids.filter(parent=None)
  total = bids.aggregate(Sum('total'))['total__sum'] or Decimal('0.00')
  choiceTotal = bids.filter(goal=None).aggregate(Sum('total'))['total__sum'] or Decimal('0.00')
  challengeTotal = bids.exclude(goal=None).aggregate(Sum('total'))['total__sum'] or Decimal('0.00')
  bids = viewutil.get_tree_queryset_descendants(Bid, bids, include_self=True).prefetch_related('options')
  bids = bids.filter(parent=None)
  
  if event.id:
    bidNameSpan = 2
  else:
    bidNameSpan = 1
    
  return views_common.tracker_response(request, 'tracker/bidindex.html', { 'searchForm': searchForm, 'bids': bids, 'total': total, 'event': event, 'bidNameSpan' : bidNameSpan, 'choiceTotal': choiceTotal, 'challengeTotal': challengeTotal })
开发者ID:uraniumanchor,项目名称:sda-donation-tracker-2-read-only,代码行数:30,代码来源:public.py

示例7: password_reset_confirm

def password_reset_confirm(request):
  uidb64 = request.GET['uidb64']
  token = request.GET['token']
  return djauth_views.password_reset_confirm(request,
    uidb64,
    token,
    template_name='tracker/password_reset_confirm.html',
    extra_context={'event': viewutil.get_event(None), 'csrftoken': get_csrf_token(request)})
开发者ID:uraniumanchor,项目名称:sda-donation-tracker-2-read-only,代码行数:8,代码来源:auth.py

示例8: handle

 def handle(self, *args, **options):
     event = viewutil.get_event(options['event'])
     prizes = prizemail.prizes_with_submission_email_pending(event)
     emailTemplate = options['template'] or event.prizecontributoremailtemplate
     
     if emailTemplate == None:
         print("No default prize accept/deny email template specified on event {0}, cannot send e-mails.".format(event.short))
     else:
         prizemail.automail_prize_contributors(event, prizes, emailTemplate)
开发者ID:DreadWingKnight,项目名称:donation-tracker,代码行数:9,代码来源:send_prize_contributor_emails.py

示例9: donorindex

def donorindex(request, event=None):
    event = viewutil.get_event(event)
    orderdict = {
        "name": ("donor__lastname", "donor__firstname"),
        "total": ("donation_total",),
        "max": ("donation_max",),
        "avg": ("donation_avg",),
    }
    page = request.GET.get("page", 1)
    sort = request.GET.get("sort", "name")

    if sort not in orderdict:
        sort = "name"

    try:
        order = int(request.GET.get("order", 1))
    except ValueError:
        order = 1

    donors = DonorCache.objects.filter(event=event.id if event.id else None).order_by(*orderdict[sort])
    if order == -1:
        donors = donors.reverse()

    fulllist = request.user.has_perm("tracker.view_full_list") and page == "full"
    pages = paginator.Paginator(donors, 50)

    if fulllist:
        pageinfo = {
            "paginator": pages,
            "has_previous": False,
            "has_next": False,
            "paginator.num_pages": pages.num_pages,
        }
        page = 0
    else:
        try:
            pageinfo = pages.page(page)
        except paginator.PageNotAnInteger:
            pageinfo = pages.page(1)
        except paginator.EmptyPage:
            pageinfo = pages.page(pages.num_pages)
            page = pages.num_pages
        donors = pageinfo.object_list

    return views_common.tracker_response(
        request,
        "tracker/donorindex.html",
        {
            "donors": donors,
            "event": event,
            "pageinfo": pageinfo,
            "page": page,
            "fulllist": fulllist,
            "sort": sort,
            "order": order,
        },
    )
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:57,代码来源:public.py

示例10: handle

 def handle(self, *args, **options):
     event = viewutil.get_event(options['event'])
     prizeWinners = prizemail.prizes_with_winner_accept_email_pending(event)
     emailTemplate = options['template'] or event.prizewinneracceptemailtemplate
     
     if emailTemplate == None:
         print("No default prize winner accepted email template specified on event {0}, cannot send e-mails.".format(event.short))
     else:
         prizemail.automail_winner_accepted_prize(event, prizeWinners, emailTemplate)
开发者ID:DreadWingKnight,项目名称:donation-tracker,代码行数:9,代码来源:send_prize_winner_accept_emails.py

示例11: donor

def donor(request,id,event=None):
  try:
    event = viewutil.get_event(event)
    donor = DonorCache.objects.get(donor=id,event=event.id if event.id else None)
    donations = donor.donation_set.filter(transactionstate='COMPLETED')
    if event.id:
      donations = donations.filter(event=event)
    comments = 'comments' in request.GET
    return tracker_response(request, 'tracker/donor.html', { 'donor' : donor, 'donations' : donations, 'comments' : comments, 'event' : event })
  except DonorCache.DoesNotExist:
    return tracker_response(request, template='tracker/badobject.html', status=404)
开发者ID:quinox,项目名称:sda-donation-tracker-2,代码行数:11,代码来源:views.py

示例12: donor

def donor(request,id,event=None):
  try:
    event = viewutil.get_event(event)
    donor = Donor.objects.get(pk=id)
    donations = donor.donation_set.filter(transactionstate='COMPLETED');
    if event.id:
      donations = donations.filter(event=event)
    comments = 'comments' in request.GET
    agg = donations.aggregate(amount=Sum('amount'), count=Count('amount'), max=Max('amount'), avg=Avg('amount'))
    return tracker_response(request, 'tracker/donor.html', { 'donor' : donor, 'donations' : donations, 'agg' : agg, 'comments' : comments, 'event' : event })
  except Donor.DoesNotExist:
    return tracker_response(request, template='tracker/badobject.html', status=404)
开发者ID:MageParts,项目名称:sda-donation-tracker-2,代码行数:12,代码来源:views.py

示例13: handle

    def handle(self, *args, **options):
        super(Command, self).handle(*args, **options)

        event = viewutil.get_event(options['event'])
        prizeWinners = prizemail.prizes_with_winner_accept_email_pending(event)
        emailTemplate = options['template'] or event.prizewinneracceptemailtemplate
        dryRun = options['dry_run']

        if emailTemplate == None:
            self.message("No default prize winner accepted email template specified on event {0}, cannot send e-mails.".format(event.short))
        else:
            prizemail.automail_winner_accepted_prize(event, prizeWinners, emailTemplate, verbosity=self.verbosity, dry_run=dryRun)
开发者ID:Seldszar,项目名称:donation-tracker,代码行数:12,代码来源:send_prize_winner_accept_emails.py

示例14: runindex

def runindex(request,event=None):
  event = viewutil.get_event(event)
  searchForm = RunSearchForm(request.GET)
  if not searchForm.is_valid():
    return HttpResponse('Invalid Search Data', status=400)
  searchParams = {}
  searchParams.update(request.GET)
  searchParams.update(searchForm.cleaned_data)
  if event.id:
    searchParams['event'] = event.id
  runs = filters.run_model_query('run', searchParams, user=request.user)
  runs = runs.select_related('runners').annotate(hasbids=Sum('bids'))
  return tracker_response(request, 'tracker/runindex.html', { 'searchForm': searchForm, 'runs' : runs, 'event': event })
开发者ID:quinox,项目名称:sda-donation-tracker-2,代码行数:13,代码来源:views.py

示例15: prizeindex

def prizeindex(request,event=None):
  event = viewutil.get_event(event)
  searchForm = PrizeSearchForm(request.GET)
  if not searchForm.is_valid():
    return HttpResponse('Invalid Search Data', status=400)
  searchParams = {}
  searchParams.update(request.GET)
  searchParams.update(searchForm.cleaned_data)
  if event.id:
    searchParams['event'] = event.id
  prizes = filters.run_model_query('prize', searchParams, user=request.user)
  prizes = prizes.select_related('startrun','endrun','category').prefetch_related('prizewinner_set')
  return tracker_response(request, 'tracker/prizeindex.html', { 'searchForm': searchForm, 'prizes' : prizes, 'event': event })
开发者ID:quinox,项目名称:sda-donation-tracker-2,代码行数:13,代码来源:views.py


注:本文中的tracker.viewutil.get_event函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。