def do(self): users = User.objects.filter(~Q(profile__membership_order=None)) for user in users: expiry =user.profile.membership_expiration_datetime if now() <= expiry: email.send_reminder('Membership Expired', user) email.send_moderate('Membership Expired', context={'user': user}) user.profile.membership_order = None user.profile.membership_level = 'A' user.profile.save()
def do(self): events = Event.objects.need_reminder().all() for event in events: regs = EventRegistration.objects.filter(~Q(reminder=True), ~Q(paid=True), event=event.pk) for reg in regs: context = { 'event': event, 'reg': reg } email.send_reminder(self.email_title, reg.user, context) reg.reminder = True reg.save()
def handle_membership(profile, order): if profile.membership_product_variation: for order_item in order.items.all(): variation = ProductVariation.objects.get(sku=order_item.sku) for category in variation.product.categories.all(): if category.title.startswith('Membership'): profile.cancel_membership() profile.membership_order = order profile.save() # Send confirmation send_reminder("Membership Purchase Confirmation", profile.user, context={'order': order}) return
def do(self): users = User.objects.filter(~Q(profile__membership_order=None)) for user in users: expiry = user.profile.membership_expiration_datetime type = user.profile.membership_payment_type if type == 'Annual': # 3 months before limit = expiry - relativedelta(months=3) elif type == 'Quarterly': # 1 month before limit = expiry - relativedelta(months=1) elif type == 'Monthly': # 1 week before limit = expiry - relativedelta(weeks=1) if limit and now() <= limit: email.send_reminder('Membership Expiring', user)
def do(self): events = Event.objects.need_freeing().all() for event in events: counter = 0 regs = EventRegistration.objects.filter(event=event) for reg in regs: if not reg.paid: # Remove counter += 1 email.send_reminder('Event seat reservation released', reg.user, context={'event': event}) else: # Send Reminder email.send_reminder('Event reminder', reg.user, context={'event': event}) if counter > 0: # Set event to not full if there are people who has not paid event.full = False event.save()
def do(self): events = Event.objects.filter(date_start__lte=now(), closed=False) for event in events: event.status = 1 event.closed = True regs = EventRegistration.objects.filter(event=event) if event.provider: if event.provider.email: email.send_reminder('Event finished', event.provider, context={'event': event}) # To Provider for reg in regs: email.send_reminder('Event finished', reg.user, context={'event': event}) # To Attendees if event.survey_before: event.survey_before.closed = True event.survey_before.save() event.save()
def signup(request, slug): if 'aftercheckout' in request.session: del request.session['aftercheckout'] event = Event.objects.get(slug=slug) if request.method == 'POST': # Check if such registration already exists exists = False if not event.is_full(): for existing in EventRegistration.objects.filter(user=request.user, event=event): messages.warning(request, 'You are already signed up to this event') exists = True if not exists: if event.event_product: variation = ProductVariation.objects.get(sku='EVENT-%s' % event.pk) request.cart.add_item(variation, 1) recalculate_cart(request) messages.success(request, 'To complete the registration, please go through the checkout.') # Send event registration confirmation send_reminder("Event Registration Pending.", request.user, context={'event':event}) else: registration = EventRegistration.objects.create(user=request.user, event=event) # Send event registration confirmation send_reminder("Event Registration Complete.", request.user, context={'event':event}) messages.success(request, 'Thank you! You signed up to the event successfully.') if event.max_seats == len(EventRegistration.objects.filter(event=event)): event.full = True event.save() # Send event registration for provider attendees = EventRegistration.objects.filter(event=event) send_reminder("Event is now full", event.provider, context={'event':event, 'attendees':attendees}) # Send event registration for provider send_reminder("A user registered for your event", event.provider, context={'event':event, 'attendee':request.user}) else: messages.warning(request, 'The event is full.') return HttpResponseRedirect(event.get_absolute_url()) context = RequestContext(request, locals()) return render_to_response('bccf/event_signup.html', {}, context_instance=context)
def handle_event(request, user, order): """ Check if the order has events in it. Process the even and register the user. """ for order_item in order.items.all(): variation = ProductVariation.objects.get(sku=order_item.sku) if order_item.sku.startswith('EVENT-'): sku_parts = order_item.sku.split('EVENT-') event = Event.objects.get(id=int(sku_parts[1])) paid = False # If payment is paypal everything is good! if order.payment_method == 'paypal': order.status = 2 order.save() paid = True # Adds a the payment to the total payment for the professional after a cut if not event.provider.is_superuser: cut = event.price * Decimal(Settings.get_setting('BCCF_PERCENTAGE_CUT')) price = event.price - cut profile = event.provider.profile if not profile.payment: profile.payment = price else: profile.payment += price profile.save() if user.profile.is_organization: user_ids = request.session.get('register_selected_members', []) event_id = request.session.get('register_selected_event', None) if not event_id: log.debug('event ID is None') return if event_id != event: continue event = Event.objects.get(id=event_id) members = [] for user_id in user_ids: u = User.objects.get(id=user_id) members.append(u) EventRegistration.objects.create(user=user, event=event, event_order=order, paid=paid) send_reminder("Event Registration Complete.", u, context={'event':event}) send_reminder("Event Registration Complete.", request.user, context={'event': event, 'members': members}) del request.session['register_selected_members'] del request.session['register_selected_event'] else: EventRegistration.objects.create(user=user, event=event, event_order=order, paid=paid) # Send confirmation send_reminder("Event Registration Complete.", request.user, context={'event':event}) return