本文整理汇总了Python中pyconde.conference.models.current_conference函数的典型用法代码示例。如果您正苦于以下问题:Python current_conference函数的具体用法?Python current_conference怎么用?Python current_conference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了current_conference函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: clean_code
def clean_code(self):
try:
code = self.cleaned_data['code']
ticket = self.instance
voucher = None
if not ticket.voucher or ticket.voucher.code != code:
voucher = Voucher.objects.valid().get(
code=code,
type__conference=current_conference(),
type=ticket.ticket_type.vouchertype_needed)
# Make sure that the found voucher is not one of the locked ones.
cache = get_cache('default')
if cache.get('voucher_lock:{0}'.format(voucher.pk)) and\
not utils.voucher_is_locked_for_session(
self.request, voucher):
raise Voucher.DoesNotExist()
except Voucher.DoesNotExist:
raise forms.ValidationError(_('Voucher verification failed.'))
return code
开发者ID:02strich,项目名称:djep,代码行数:21,代码来源:forms.py
示例17: get_queryset
def get_queryset(self):
qs = models.ProposalMetaData.objects \
.select_related('proposal', 'proposal__track',
'proposal__kind',
'latest_proposalversion') \
.only('proposal__kind', 'proposal__track',
'proposal__title', 'proposal__id',
'score', 'num_reviews', 'num_comments',
'latest_proposalversion__id',
'latest_proposalversion__title',
'latest_activity_date',
'latest_comment_date') \
.order_by(self.get_order()) \
.filter(proposal__conference_id=current_conference().id)
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:DanielSzoska,项目名称:djep,代码行数:22,代码来源:views.py
示例18: form_valid
def form_valid(self, form):
reviewer_request = Reviewer.objects.create(user=self.request.user, conference=current_conference())
reviewer_ct = ContentType.objects.get_for_model(Reviewer)
perm = auth_models.Permission.objects.get(content_type_id=reviewer_ct.pk, codename='change_reviewer')
mails = []
subject = _('New reviewer application')
from_email = settings.DEFAULT_FROM_EMAIL
url = 'https://' if self.request.is_secure() else 'http://'
url += self.request.get_host()
url += reverse('admin:reviews_reviewer_change', args=(reviewer_request.pk,))
data_dict = {
'applicant_username': self.request.user.username,
'applicant_display_name': get_display_name(self.request.user),
'reviewer_list_url': url,
'conference_title': current_conference().title,
}
for user in perm.user_set.all():
data_dict['receiver'] = get_addressed_as(user)
message = render_to_string('accounts/reviewer_application_mail.txt', data_dict)
mails.append((subject, message, from_email, [user.email]))
send_mass_mail(mails)
return super(ReviewerApplication, self).form_valid(form)
开发者ID:02strich,项目名称:djep,代码行数:23,代码来源:views.py
示例19: get_context_data
def get_context_data(self, **kwargs):
comment_form = forms.CommentForm()
comment_form.helper.form_action = reverse('reviews-submit-comment', kwargs={'pk': self.object.pk})
comments = self.object.comments.select_related('proposal_version', 'author').all()
proposal_versions = self.object.versions.select_related('creator').all()
data = super(ProposalDetailsView, self).get_context_data(**kwargs)
data['comments'] = comments
data['proposal_version'] = models.ProposalVersion.objects.get_latest_for(self.object)
data['comment_form'] = comment_form
data['versions'] = proposal_versions
data['timeline'] = map(self.wrap_timeline_elements, utils.merge_comments_and_versions(comments, proposal_versions))
data['can_review'] = utils.can_review_proposal(self.request.user, self.object) and not utils.is_proposal_author(self.request.user, self.object)
data['can_update'] = utils.is_proposal_author(self.request.user, self.object)
data['can_comment'] = utils.can_participate_in_review(self.request.user, self.object) and current_conference().get_reviews_active()
try:
review = self.object.reviews.get(user=self.request.user)
data['user_review'] = review
data['review_outdated'] = review.proposal_version != data['proposal_version']
except:
pass
return data
开发者ID:bmispelon,项目名称:djep,代码行数:21,代码来源:views.py
示例20: customize_fields
def customize_fields(self, instance=None, form=None, tracks=None):
if form is None:
form = self
if tracks is None:
tracks = conference_models.Track.current_objects.all()
if not settings.SUPPORT_ADDITIONAL_SPEAKERS:
del form.fields['additional_speakers']
else:
# Only list already selected speakers or an empty queryset
if instance is not None:
additional_speakers = instance.additional_speakers.all()
else:
additional_speakers = speaker_models.Speaker.objects.none()
form.fields['additional_speakers'] = HiddenSpeakersMultipleChoiceField(label=_("Additional speakers"),
queryset=additional_speakers, required=False)
if 'kind' in self.fields:
form.fields['kind'] = forms.ModelChoiceField(label=_("Type"),
queryset=conference_models.SessionKind.current_objects.filter_open_kinds())
if 'audience_level' in self.fields:
form.fields['audience_level'] = forms.ModelChoiceField(label=_("Target-audience"),
queryset=conference_models.AudienceLevel.current_objects.all())
if 'duration' in self.fields:
form.fields['duration'] = forms.ModelChoiceField(label=_("Duration"),
queryset=conference_models.SessionDuration.current_objects.all())
if 'track' in self.fields:
form.fields['track'] = forms.ModelChoiceField(label=_("Track"), required=True, initial=None,
queryset=tracks)
if 'abstract' in self.fields:
form.fields['abstract'].help_text = _("""Up to around 50 words. Appears in the printed program. <br />This field supports <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank" rel="external">Markdown</a> input.""")
# form.fields['abstract'].validators = [validators.MaxLengthValidator(3000)]
if 'description' in form.fields:
form.fields['description'].help_text = _("""Describe your presentation in detail. This is what will be reviewed during the review phase.<br />This field supports <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank" rel="external">Markdown</a> input.""")
# form.fields['description'].validators = [validators.MaxLengthValidator(2000)]
if 'additional_speakers' in form.fields:
form.fields['additional_speakers'].help_text = _("""If you want to present with others, please enter their names here.""")
if 'available_timeslots' in form.fields:
form.fields['available_timeslots'] = forms.ModelMultipleChoiceField(
label=_("Available timeslots"),
queryset=models.TimeSlot.objects.select_related('section').filter(section__conference=conference_models.current_conference()).order_by('date', 'slot'),
widget=forms.CheckboxSelectMultiple,
required=False
)
form.fields['available_timeslots'].help_text += ugettext(
"""<br /><br />Please pick all the times that should be considered for your """
"""presentation/training. If possible these will be used for the final timeslot.""")
if 'notes' in form.fields:
form.fields['notes'].help_text = _(
"""Add notes or comments here that can only be seen by reviewers and the organizing team.""")
if 'accept_recording' in form.fields:
form.fields['accept_recording'].label =_(
"""I agree to allow the Python Software Verband e.V. to record my presentation on EuroPython 2014 in Berlin.""")
if 'language' in form.fields:
form.fields['language'].initial = settings.DEFAULT_LANGUAGE
开发者ID:DasIch,项目名称:djep,代码行数:53,代码来源:forms.py
注:本文中的pyconde.conference.models.current_conference函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论