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


Python models.current_conference函数代码示例

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


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

示例1: can_see_proposal_author

def can_see_proposal_author(user):
    if (
        conference_models.current_conference() is not None and
        not conference_models.current_conference().anonymize_proposal_author
    ):
        return True
    if user.has_perm('proposals.see_proposal_author'):
        return True
    return False
开发者ID:DanielSzoska,项目名称:djep,代码行数:9,代码来源:utils.py

示例2: post

    def post(self, *args, **kwargs):
        self.clear_purchase_info()
        self.form = forms.PurchaseForm(self.request.POST)

        # Create a quantity for for each available ticket type.
        self.quantity_forms = []
        all_quantity_forms_valid = True
        self.total_ticket_num = 0
        ticket_types = TicketType.objects.available().filter(
            conference=current_conference())
        for ticket_type in ticket_types:
            quantity_form = forms.TicketQuantityForm(
                data=self.request.POST,
                ticket_type=ticket_type)

            if quantity_form.is_valid():
                ticket_quantity = quantity_form.cleaned_data.get(
                    'quantity', 0)
                if ticket_quantity is None:
                    ticket_quantity = 0
                self.total_ticket_num += ticket_quantity
            else:
                all_quantity_forms_valid = False

            self.quantity_forms.append(quantity_form)

        # Address, quantities (limits) and at least one ticket must be bought
        if self.form.is_valid() and all_quantity_forms_valid\
                and self.total_ticket_num > 0:
            purchase = self.form.save(commit=False)
            if self.request.user.is_authenticated():
                purchase.user = self.request.user
            purchase.conference = current_conference()

            # Create a ticket for each ticket type and amount
            for quantity_form in self.quantity_forms:
                ticket_quantity = quantity_form.cleaned_data.get('quantity', 0)
                if ticket_quantity is None:
                    ticket_quantity = 0
                for _i in range(0, ticket_quantity):
                    ticket_model = quantity_form.ticket_type.content_type.model_class()
                    self.tickets.append(
                        ticket_model(purchase=purchase,
                               ticket_type=quantity_form.ticket_type))
            purchase.payment_total = purchase.calculate_payment_total(
                tickets=self.tickets)
            self.purchase = purchase

            # Please note that we don't save the purchase object nor the
            # freshly created tickets yet but instead put them just into
            # the session.
            self.save_state()

            return redirect('attendees_purchase_names')

        return self.get(*args, **kwargs)
开发者ID:DanielSzoska,项目名称:djep,代码行数:56,代码来源:views.py

示例3: get_context_data

 def get_context_data(self, **kwargs):
     this_speaker = self.request.user.speaker_profile
     ctx = super(ListUserProposalsView, self).get_context_data(**kwargs)
     ctx.update({
         'proposals': this_speaker.proposals
         .filter(conference=current_conference()).all(),
         'proposal_participations': this_speaker.proposal_participations
         .filter(conference=current_conference()).all()
     })
     return ctx
开发者ID:SofiaMargariti,项目名称:djep,代码行数:10,代码来源:views.py

示例4: handle

    def handle(self, *args, **options):
        necessary_slots = set()
        all_slots = set()
        created_slots = set()
        for section in conference_models.Section.current_objects.all():
            if section.start_date and section.end_date:
                for date in utils.get_date_range(section.start_date, section.end_date):
                    for slot in models.DATE_SLOT_CHOICES:
                        obj, created = models.TimeSlot.objects.get_or_create(
                            date=date, slot=slot[0], section=section)
                        necessary_slots.add(obj)
                        if created:
                            LOG.info("Created {0}".format(obj))
                            created_slots.add(obj)
            else:
                LOG.warn("Section {0} has no valid date range!".format(
                    section))
        all_slots.update(list(models.TimeSlot.objects.filter(section__conference=conference_models.current_conference())))

        print("Created {0} slots".format(len(created_slots)))
        unnecessary_slots = all_slots - necessary_slots
        if unnecessary_slots:
            print("Found unnecssary slots:")
            for slot in unnecessary_slots:
                print(" - {0}".format(slot))
开发者ID:DanielSzoska,项目名称:djep,代码行数:25,代码来源:create_proposal_timeslots.py

示例5: send_proposal_update_notification

def send_proposal_update_notification(version, notify_author=False):
    """
    Send a version notification mail to all users related to the version's
    proposal except for the author of the version unless notify_author=True
    is passed.
    """
    proposal = version.original
    current_user = version.creator
    if notify_author:
        current_user = None
    hide_author = conference_models.current_conference().anonymize_proposal_author and\
        is_proposal_author(current_user, proposal)
    body = render_to_string('reviews/emails/version_notification.txt', {
        'version': version,
        'proposal': proposal,
        'site': Site.objects.get_current(),
        'hide_author': hide_author,
        'proposal_url': reverse('reviews-proposal-details', kwargs={'pk': proposal.pk}),
    })
    if hide_author:
        subject = _("[REVIEW] The author updated %(title)s")
    else:
        subject = _("[REVIEW] %(author)s updated %(title)s")
    msg = EmailMessage(subject=subject % {
            'author': account_utils.get_display_name(version.creator),
            'title': proposal.title},
        bcc=[u.email for u in get_people_to_notify(proposal, current_user)],
        body=body)
    msg.send()
开发者ID:02strich,项目名称:djep,代码行数:29,代码来源:utils.py

示例6: __init__

 def __init__(self, output=None, conference=None):
     self.output = output
     self.conference = conference
     if self.output is None:
         self.output = sys.stdout
     if self.conference is None:
         self.conference = conference_models.current_conference()
开发者ID:DanielSzoska,项目名称:djep,代码行数:7,代码来源:exporters.py

示例7: send_comment_notification

def send_comment_notification(comment, notify_author=False):
    """
    Send a comment notification mail to all users related to the comment's
    proposal except for the author of the comment unless notify_author=True
    is passed.
    """
    proposal = comment.proposal
    current_user = comment.author
    if notify_author:
        current_user = None
    # WARNING: We cannot use `can_see_proposal_author` here, because we
    #          write a BCC mail to all involved reviewers and there will
    #          probably be at least one not allowed to see the author
    hide_author = conference_models.current_conference().anonymize_proposal_author and\
        is_proposal_author(comment.author, proposal)
    body = render_to_string('reviews/emails/comment_notification.txt', {
        'comment': comment,
        'proposal': proposal,
        'hide_author': hide_author,
        'site': Site.objects.get_current(),
        'proposal_url': reverse('reviews-proposal-details', kwargs={'pk': proposal.pk}),
    })
    if hide_author:
        subject = _("[REVIEW] The author has commented on \"%(title)s\"")
    else:
        subject = _("[REVIEW] %(author)s commented on \"%(title)s\"")
    msg = EmailMessage(subject=subject % {
            'author': account_utils.get_display_name(comment.author),
            'title': proposal.title},
        bcc=[u.email for u in get_people_to_notify(proposal, current_user)
             if has_valid_mailaddr(u)],
        body=body)
    msg.send()
开发者ID:DanielSzoska,项目名称:djep,代码行数:33,代码来源:utils.py

示例8: form_valid

 def form_valid(self, form):
     obj = form.save(commit=False)
     obj.speaker = self.request.user.speaker_profile
     # TODO: Filter out duplications between speaker and additional speakers
     obj.conference = current_conference()
     obj.save()
     self.object = obj
     form.save_m2m()
     return HttpResponseRedirect(self.get_success_url())
开发者ID:SofiaMargariti,项目名称:djep,代码行数:9,代码来源:views.py

示例9: render

 def render(self, context):
     conference = current_conference()
     if self.level:
         level = self.level.resolve(context)
         queryset = Sponsor.objects.filter(level__conference = conference, level__slug__iexact = level, active = True).order_by("added")
     else:
         queryset = Sponsor.objects.filter(level__conference = conference, active = True).order_by("level__order", "added")
     context[self.context_var] = queryset
     return u""
开发者ID:DanielSzoska,项目名称:djep,代码行数:9,代码来源:sponsorship_tags.py

示例10: get_queryset

 def get_queryset(self):
     qs = models.ProposalMetaData.objects.select_related('proposal', 'proposal__track', 'proposal__kind').order_by(self.get_order()).all()
     qs = qs.filter(proposal__conference=current_conference())
     if self.filter_form.is_valid():
         track_slug = self.filter_form.cleaned_data['track']
         kind_slug = self.filter_form.cleaned_data['kind']
         if track_slug:
             qs = qs.filter(proposal__track__slug=track_slug)
         if kind_slug:
             qs = qs.filter(proposal__kind__slug=kind_slug)
     return qs
开发者ID:bmispelon,项目名称:djep,代码行数:11,代码来源:views.py

示例11: __init__

    def __init__(self, *args, **kwargs):
        assert 'instance' in kwargs, 'instance is required.'

        super(TicketNameForm, self).__init__(
            prefix='tn-%s' % kwargs['instance'].pk, *args, **kwargs)

        self.fields['first_name'].required = True
        self.fields['last_name'].required = True
        self.fields['shirtsize'].queryset = self.fields['shirtsize']\
            .queryset.filter(conference=current_conference())
        self.fields['shirtsize'].help_text = _('''Sizing charts: <a href="http://maxnosleeves.spreadshirt.com/shop/info/producttypedetails/Popup/Show/productType/813" target="_blank">Women</a>, <a href="http://maxnosleeves.spreadshirt.com/shop/info/producttypedetails/Popup/Show/productType/812" target="_blank">Men</a>''')
开发者ID:02strich,项目名称:djep,代码行数:11,代码来源:forms.py

示例12: wrap_timeline_elements

 def wrap_timeline_elements(self, item):
     type_ = 'comment'
     user = None
     if isinstance(item, models.ProposalVersion):
         type_ = 'version'
         user = item.creator
     else:
         user = item.author
     return {
         'type': type_,
         'item': item,
         'hide_author': current_conference().anonymize_proposal_author and utils.is_proposal_author(user, self.object),
     }
开发者ID:bmispelon,项目名称:djep,代码行数:13,代码来源:views.py

示例13: handle

 def handle(self, *args, **options):
     max_in_db = models.Purchase.objects\
         .filter(conference=current_conference())\
         .aggregate(Max('invoice_number'))\
         .get('invoice_number__max', 0)
     redis = get_redis_connection()
     redis_value = redis.get(settings.INVOICE_NUMBER_SEQUENCE_NAME)
     if redis_value is None:
         redis_value = 0
     else:
         redis_value = int(redis_value)
     if redis_value != max_in_db:
         print("Sequence stored in Redis is different from latest invoice in database: {0} vs. {1}".format(
             redis_value, max_in_db), file=sys.stderr)
         sys.exit(1)
     else:
         print("OK")
开发者ID:DanielSzoska,项目名称:djep,代码行数:17,代码来源:check_invoice_number.py

示例14: export

 def export(self):
     output = StringIO.StringIO()
     with etree.xmlfile(output) as xf:
         sessions = models.Session.objects \
             .select_related('kind', 'audience_level', 'track',
                             'speaker__user__profile') \
             .prefetch_related('additional_speakers__user__profile',
                               'location') \
             .filter(released=True, start__isnull=False, end__isnull=False,
                     kind__slug__in=('talk', 'keynote', 'sponsored')) \
             .order_by('start') \
             .only('end', 'start', 'title', 'abstract', 'description', 'language',
                   'kind__name',
                   'audience_level__name',
                   'track__name',
                   'speaker__user__username',
                   'speaker__user__profile__avatar',
                   'speaker__user__profile__full_name',
                   'speaker__user__profile__display_name',
                   'speaker__user__profile__short_info',
                   'speaker__user__profile__user') \
             .all()
         side_events = models.SideEvent.objects \
             .select_related() \
             .prefetch_related('location') \
             .filter(start__isnull=False, end__isnull=False, is_recordable=True) \
             .order_by('start') \
             .only('end', 'start', 'name') \
             .all()
         self.conference = force_text(conference_models.current_conference())
         self._duration_base = datetime.datetime.combine(datetime.date.today(), datetime.time(0, 0, 0))
         with xf.element('iCalendar'):
             with xf.element('vcalendar'):
                 with xf.element('version'):
                     xf.write('2.0')
                 with xf.element('prodid'):
                     xf.write('-//Pentabarf//Schedule %s//EN' % self.conference)
                 with xf.element('x-wr-caldesc'):
                     xf.write(self.conference)
                 with xf.element('x-wr-calname'):
                     xf.write(self.conference)
                 for session in sessions:
                     self._export_session(xf, session)
                 for session in side_events:
                     self._export_side_event(xf, session)
     return output
开发者ID:DanielSzoska,项目名称:djep,代码行数:46,代码来源:exporters.py

示例15: __init__

    def __init__(self, *args, **kwargs):
        assert 'instance' in kwargs, 'instance is required.'

        super(TicketNameForm, self).__init__(
            prefix='tn-%s' % kwargs['instance'].pk, *args, **kwargs)

        self.fields['first_name'].required = True
        self.fields['last_name'].required = True
        self.fields['organisation'].required = False
        self.fields['dietary_preferences'] = forms.ModelMultipleChoiceField(
            label=mark_safe(pgettext('nameform', 'Dietary preferences')),
            queryset=DietaryPreference.objects.all(),
            required=False,
            widget=forms.CheckboxSelectMultiple
        )
        if 'dietary_preferences' in kwargs['instance'].related_data:
            self.initial['dietary_preferences'] = [obj.pk for obj in kwargs['instance'].related_data.get('dietary_preferences', [])]
        self.fields['shirtsize'].queryset = self.fields['shirtsize']\
            .queryset.filter(conference=current_conference())
        self.fields['shirtsize'].help_text = _('''Sizing charts: <a href="http://maxnosleeves.spreadshirt.com/shop/info/producttypedetails/Popup/Show/productType/813" target="_blank">Women</a>, <a href="http://maxnosleeves.spreadshirt.com/shop/info/producttypedetails/Popup/Show/productType/812" target="_blank">Men</a>''')
开发者ID:DanielSzoska,项目名称:djep,代码行数:20,代码来源:forms.py


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