Ejemplo n.º 1
0
    def process(self, data, **kwargs):
        from pprint import pformat
        logging.info('valid: ' + pformat(self.request.arguments))

        txn = kwargs['txn']
        invoice = kwargs['invoice']

        txn.verification_status = VERIFICATION_STATUS_VERIFIED
        txn.put()

        if txn.transaction_type == 'subscr_payment':
            payment_status = data.get('payment_status')
            if payment_status == 'Pending':
                invoice.status = INVOICE_STATUS_PENDING
                invoice.status_reason = data.get('pending_reason')
                invoice.put()
            elif payment_status == 'Completed':
                if data.get('receiver_email') == configuration.PAYPAL_MERCHANT_RECEIVER_EMAIL \
                       and invoice.total_price == txn.amount \
                       and txn.currency == invoice.currency:
                    invoice.status = INVOICE_STATUS_COMPLETE
                    invoice.put()
                    # Email success and activation code.
                    from workers import WORKER_MAIL_ACTIVATION_URL
                    queue_mail_task(
                        url=WORKER_MAIL_ACTIVATION_URL, 
                        params=dict(
                            invoice_key = str(invoice.key())
                        ),
                        method='POST')
                else:
                    pass
Ejemplo n.º 2
0
    def post(self, key):
        presentation_filename = self.request.get("presentation_filename")
        speaker = Speaker()
        speaker.full_name = self.request.get("full_name")
        speaker.designation = self.request.get("designation")
        speaker.organization = self.request.get("organization")
        speaker.department = self.request.get("department")
        speaker.organization_website = self.request.get("organization_website")
        speaker.city = self.request.get("city")
        speaker.email = self.request.get("email")
        speaker.mobile_number = self.request.get("mobile_number")
        speaker.research_topic = self.request.get("research_topic")
        speaker.bio_sketch = self.request.get("bio_sketch")
        if presentation_filename:
            presentation = Presentation()
            presentation.filename = self.request.get("presentation_filename")
            presentation.content = db.Blob(self.request.get("presentation"))
            presentation.extension = splitext(presentation_filename)[1]
            presentation.put()
            speaker.presentation_file = presentation
        speaker.put()

        queue_mail_task(
            url="/worker/mail/thanks/speaker_nomination/",
            params=dict(full_name=speaker.full_name, email=speaker.email, key=str(speaker.key())),
            method="POST",
        )

        self.response.out.write(speaker.to_json("full_name", "is_starred", "is_deleted", "is_active"))
Ejemplo n.º 3
0
    def get(self):
        today = datetime.utcnow()
        training_programs = TrainingProgram.get_all_payable_for_date(today.year, today.month, today.day)
        for training_program in training_programs:
#            if not training_program.is_registration_closed:
            fees = training_program.get_fees_sorted()
            count = training_program.get_participant_count()

            current_fee = max([f.fee for f in fees])
            for fee in fees:
                if count <= fee.for_participant_count:
                    current_fee = fee.fee
                else:
                    continue
            training_program.final_price = current_fee
            training_program.put()

            for registrant in training_program.registrants:
                queue_mail_task(url='/worker/mail/training_announcement_payment_notification/',
                    params=dict(
                        registrant_key=str(registrant.key()),
                        training_program_key=str(training_program.key()),
                        current_fee=current_fee
                    ),
                    method='POST'
                )
Ejemplo n.º 4
0
    def post(self, key):
        presentation_filename = self.request.get('presentation_filename')
        speaker = Speaker()
        speaker.full_name = self.request.get('full_name')
        speaker.designation = self.request.get('designation')
        speaker.organization = self.request.get('organization')
        speaker.department = self.request.get('department')
        speaker.organization_website = self.request.get('organization_website')
        speaker.city = self.request.get('city')
        speaker.email = self.request.get('email')
        speaker.mobile_number = self.request.get('mobile_number')
        speaker.research_topic = self.request.get('research_topic')
        speaker.bio_sketch = self.request.get('bio_sketch')
        if presentation_filename:
            speaker.presentation = self.request.get('presentation')
            speaker.presentation_filename = self.request.get('presentation_filename')
            speaker.presentation_extension = splitext(presentation_filename)[1]
        speaker.put()

        queue_mail_task(url='/worker/mail/thanks/speaker_nomination/',
            params=dict(
                full_name=speaker.full_name,
                email = speaker.email,
                key=str(speaker.key())
            ),
            method='POST'
        )

        self.response.out.write(speaker.to_json('full_name', 'is_starred', 'is_deleted', 'is_active'))
Ejemplo n.º 5
0
 def get(self, key):
     o = db.get(db.Key(key))
     o.is_active = True
     o.wants_activation = False
     o.put()
     queue_mail_task(url='/worker/mail/account_activation_notification/' + key, method='GET')
     self.response.out.write(o.is_active)
Ejemplo n.º 6
0
    def get(self, key):
        mail = db.get(db.Key(key))

        today = datetime.utcnow()


        to_emails = mail.to_emails
        users = User.get_all_by_filter(mail.to_users)
        for user in users:
            to_emails.append(user.email)
            if user.corporate_email and (not user.corporate_email == user.email):
                to_emails.append(str(user.corporate_email))

        receivers = [MailReceiver(email=email, mail=mail) for email in set(to_emails)]
        db.put(receivers)

        for receiver in receivers:
            queue_mail_task(url='/worker/mail/compose/',
                params=dict(
                    mail_key=str(mail.key()),
                    email=receiver.email
                ),
                method='POST'
            )
        mail.when_sent = today
        mail.is_active = True
        mail.put()
Ejemplo n.º 7
0
    def post(self):
        host_info = get_host_info(self.request)
        host_info.put()

        survey_participant = SurveyParticipant()
        survey_participant.full_name = self.request.get('full_name')
        survey_participant.designation = self.request.get('designation')
        survey_participant.department = self.request.get('department')
        survey_participant.job_type = self.request.get('job_type')
        survey_participant.organization = self.request.get('organization')
        survey_participant.organization_website = self.request.get('organization_website')
        survey_participant.city = self.request.get('city')
        survey_participant.email = self.request.get('email')
        survey_participant.mobile_number = self.request.get('mobile_number')
        survey_participant.host_info = host_info
        survey_participant.put()

        queue_mail_task(url='/worker/mail/thanks/survey_participation/',
            params=dict(
                full_name=survey_participant.full_name,
                email = survey_participant.email,
                survey_link=SURVEY_LINK,
                key=str(survey_participant.key())
            ),
            method='POST'
        )

        response = render_template('thank_you.html', message_title="Thank you for participating in the survey.", message_body="We appreciate you taking the time to participate in the survey.  We shall contact you within 48 hours.")
        self.response.out.write(response)
Ejemplo n.º 8
0
    def post(self):
        session_user = self.get_session_user()
        keys = json.loads(self.request.get('keys'))

        user = models.User.get_user_from_identifier(session_user.identifier)
        orders = []
        books = []
        isbn_list = []
        for key in keys:
            book = db.get(db.Key(key))
            order = models.UserBookOrder(user=user, book=book)
            books.append(str(book))
            orders.append(order)
        db.put(orders)

        person = user.people_singleton[0]
        book_infos = '\n'.join(books)

        queue_mail_task(url='/worker/mail/book_order/',
            params=dict(
                user_key=str(user.key()),
                books=book_infos,
                person_name=str(person),
                person_email_address=user.email,
                person_phone_number = str(person.phones[0])
            ),
            method='POST'
        )
        self.response.out.write(json.dumps(keys))
Ejemplo n.º 9
0
    def get(self):
        from pickle import dumps
        from ebs.merchant.api import get_ebs_request_parameters

        dr = self.request.get('DR')
        if dr:
            billing_settings = BillingSettings.get_settings(deployment_mode=ebs_mode)
            request = get_ebs_request_parameters(dr, billing_settings.secret_key)

            response_code = request.get('ResponseCode', None)
            response_message = request.get('ResponseMessage', 'There was no response from the billing system.')

            group = self.session.get('participant_group')
            group.transaction_response_id = str(request.get('PaymentID'))
            group.transaction_response_code = str(response_code)
            group.transaction_response_message = response_message
            group.transaction_response_type = TRANSACTION_TYPE_EBS
            group.transaction_response_amount = request.get('Amount', '0')
            group.transaction_response = str(request)
            group.transaction_response_object = db.Blob(dumps(request))
            group.when_transaction_response_occurred = request.get('DateCreated')
            group.put()

            if response_code == 0:
                # mark the participant group as paid.
                message_title = 'Thank you for participating in the summit'
                group_id = group.key().id()
                logging.info('Payments for group: %s with %d processed.' % (group.title, group_id))

                participants = self.session.get('participants')
                if participants:
                    # Send email to all the participants about their attendance.
                    for participant in participants:
                        queue_mail_task(url='/worker/mail/thanks/registration/',
                            params=dict(
                                full_name=participant.full_name,
                                email = participant.email,
                                key=str(participant.key())
                            ),
                            method='POST'
                        )
                    # Send email to the payer the invoice.
                    primary_participant = self.session.get('primary_participant')
                    queue_mail_task(url='/worker/mail/thanks/registration_payment/',
                        params=dict(
                            full_name=primary_participant.full_name,
                            email = primary_participant.email,
                            key=str(primary_participant.key()),
                            transaction_amount=group.transaction_response_amount
                        ),
                        method='POST'
                    )
            else:
                message_title = 'There was an error processing your payment.'
            response = render_template('thank_you.html', message_title=message_title, message_body=response_message + ''' Thank you for registering for the summit. An email confirming your payment and registration shall be sent to you shortly. In case you don't receive the email confirmation within 24 hours or you have any queries, please contact +91 22 66301060 / 22026166 from 10.30 AM IST to 6.30 AM IST''')
        else:
            response = render_template('thank_you.html', message_title="A problem occurred with the billing system.", message_body="We did not receive a proper response from the billing system.")

        self.response.out.write(response)
Ejemplo n.º 10
0
 def get(self, key):
     user = db.get(db.Key(key))
     user.is_active = True
     user.wants_activation = False
     user.put()
     User.increment_approved_user_count()
     queue_mail_task(url='/worker/mail/account_activation_notification/' + key, method='GET')
     self.response.out.write(user.is_active)
Ejemplo n.º 11
0
def activate_user_keys(keys):
    item_list = []
    for key in keys:
        item = db.get(db.Key(key))
        item.is_active = True
        item.wants_activation = False
        item_list.append(item)
        queue_mail_task(url='/worker/mail/account_activation_notification/' + key, method='GET')
    db.put(item_list)
    return keys
Ejemplo n.º 12
0
    def get(self, registrant_key, training_key):
        registrant = db.get(db.Key(registrant_key))
        registrant.is_payment_received = True
        registrant.put()

        queue_mail_task(url='/worker/mail/training_announcement_confirm_payment_notification/',
                params=dict(
                    registrant_key=registrant_key,
                    training_program_key=training_key
                ),
                method='POST'
            )
        self.response.out.write(registrant.is_payment_received)
Ejemplo n.º 13
0
 def activate(self):
     from utils import queue_mail_task
     
     self.is_active = True
     self.put()
     
     queue_mail_task(
         url='/worker/mail/activate-account',
         params=dict(
             profile_key=unicode(self.key()),
         ),
         method='POST'
     )
Ejemplo n.º 14
0
    def get(self, key):
        announcement = db.get(db.Key(key))
        announcement.is_active = True
        announcement.put()

        #users = User.all().filter('email IN', ['*****@*****.**', '*****@*****.**', '*****@*****.**']).fetch(MAX_FETCH_LIMIT)
        users = User.get_all_by_filter("approved")
        for user in users:
            queue_mail_task(url='/worker/mail/training_announcement_notification/' + str(user.key()),
                params=dict(user_key=str(user.key()),
                            training_program_key=key),
                method='GET')

        self.response.out.write(announcement.is_active)
Ejemplo n.º 15
0
    def get(self, key):
        training_program = db.get(db.Key(key))
        training_program.is_canceled = True
        #training_program.is_active = False
        training_program.put()

        for registrant in training_program.registrants:
            queue_mail_task(url='/worker/mail/training_announcement_canceled_notification/',
                params=dict(
                    registrant_key=str(registrant.key()),
                    training_program_key=key
                ),
                method='POST'
            )
        self.response.out.write(training_program.is_active)
Ejemplo n.º 16
0
    def post(self, training_program_key, registrant_key):
        training_program = db.get(db.Key(training_program_key))

        registrant = db.get(db.Key(registrant_key))
        registrant.is_active = True
        registrant.put()

        training_program.increment_participant_count()

        queue_mail_task(
            url="/worker/mail/training_announcement_registration_notification/",
            params=dict(registrant_key=registrant_key, training_program_key=training_key),
            method="POST",
        )
        self.redirect("/")
Ejemplo n.º 17
0
 def get(self):
     today = datetime.utcnow()
     training_programs = TrainingProgram.get_all_closable_for_date(today.year, today.month, today.day)
     for training_program in training_programs:
         if not training_program.is_registration_closed:
             for registrant in training_program.registrants:
                 queue_mail_task(url='/worker/mail/training_announcement/closure/',
                     params=dict(
                         registrant_key=str(registrant.key()),
                         training_program_key=str(training_program.key())
                     ),
                     method='POST'
                 )
             training_program.is_registration_closed = True
             training_program.put()
Ejemplo n.º 18
0
    def post(self):
        from models import Presentation
        
        host_info = get_host_info(self.request)
        host_info.put()

        presentation_filename = self.request.get('presentation_filename')
        presentation = self.request.get('presentation')

        speaker = Speaker()
        speaker.full_name = self.request.get('full_name')
        speaker.designation = self.request.get('designation')
        speaker.organization = self.request.get('organization')
        speaker.department = self.request.get('department')
        speaker.organization_website = self.request.get('organization_website')
        speaker.city = self.request.get('city')
        speaker.email = self.request.get('email')
        speaker.mobile_number = self.request.get('mobile_number')
        speaker.research_topic = self.request.get('research_topic')
        speaker.bio_sketch = self.request.get('bio_sketch')
        speaker.host_info = host_info
        #if presentation_filename:
        #    speaker.presentation = db.Blob(presentation)
        #    speaker.presentation_filename = presentation_filename
        #    speaker.presentation_extension = splitext(presentation_filename)[1]
        if presentation_filename:
            speaker_presentation = Presentation()
            speaker_presentation.filename = presentation_filename
            speaker_presentation.extension = splitext(presentation_filename)[1]
            speaker_presentation.content = db.Blob(presentation)
            speaker_presentation.put()
            
            speaker.presentation = speaker_presentation
        
        speaker.put()

        queue_mail_task(url='/worker/mail/thanks/speaker_nomination/',
            params=dict(
                full_name=speaker.full_name,
                email = speaker.email,
                key=str(speaker.key())
            ),
            method='POST'
        )

        response = render_template('thank_you.html', message_title='Thank you for nominating a speaker.', message_body='We appreciate your taking the time to nominating a speaker.  We will get in touch with you soon')
        self.response.out.write(response)
Ejemplo n.º 19
0
    def post(self, training_key):
        training_program = db.get(db.Key(training_key))
        nominations = dec(self.request.get("nominations_count"))

        # training_program.increment_participant_count(incr=nominations)
        training_program.increment_total_participant_count(incr=nominations)

        registrants = []
        for x in range(nominations):
            i = str(x + 1)
            full_name = self.request.get("full_name_" + i)
            phone_number = self.request.get("phone_number_" + i)
            email = self.request.get("email_" + i)
            company = self.request.get("company_" + i)
            designation = self.request.get("designation_" + i)
            registrant = TrainingProgramRegistrant()
            registrant.full_name = full_name
            registrant.phone_number = phone_number
            registrant.email = email
            # Let the admin determine who to activate.
            # registrant.is_active = True
            registrant.company = company
            registrant.designation = designation
            registrant.training_program = training_program
            registrants.append(registrant)
        db.put(registrants)

        if training_program.is_canceled:
            for registrant in registrants:
                registrant_key = str(registrant.key())
                queue_mail_task(
                    url="/worker/mail/training_announcement_canceled_notification/",
                    params=dict(registrant_key=registrant_key, training_program_key=training_key),
                    method="POST",
                )
            response = render_template("training_announcement_canceled.html", training_announcement=training_program)
            self.response.out.write(response)
        else:
            for registrant in registrants:
                registrant_key = str(registrant.key())
                queue_mail_task(
                    url="/worker/mail/training_announcement_registration_notification/",
                    params=dict(registrant_key=registrant_key, training_program_key=training_key),
                    method="POST",
                )
            self.redirect("/training_announcements/")
Ejemplo n.º 20
0
    def post(self):
        participant = Participant()
        participant.full_name = self.request.get("full_name")
        participant.email = self.request.get("email")
        participant.mobile_number = self.request.get("mobile_number")
        participant.phone_number = self.request.get("phone_number")
        participant.pricing = Decimal(self.request.get("pricing"))
        participant.designation = self.request.get("designation")
        participant.department = self.request.get("department")
        participant.organization = self.request.get("organization")
        participant.address = self.request.get("address")
        participant.put()

        queue_mail_task(
            url="/worker/mail/thanks/registration/",
            params=dict(full_name=participant.full_name, email=participant.email, key=str(participant.key())),
            method="POST",
        )
        self.response.out.write(participant.to_json("full_name", "is_starred", "is_deleted", "is_active"))
Ejemplo n.º 21
0
    def post(self, training_program_key, registrant_key):
        training_program = db.get(db.Key(training_program_key))
        registrant = db.get(db.Key(registrant_key))

        why_unregister = self.request.get("why_unregister")
        registrant.is_active = False
        registrant.why_unregister = why_unregister
        registrant.put()

        # Decrement the participant count only if the user was already active.
        if registrant.is_active:
            training_program.decrement_participant_count()

        queue_mail_task(
            url="/worker/mail/training_announcement_unregister_notification/",
            params=dict(registrant_key=registrant_key, training_program_key=training_program_key),
            method="POST",
        )

        response = render_template("unregister_thanks.html", training_announcement=training_program)
        self.response.out.write(response)
Ejemplo n.º 22
0
    def post(self):
        participant = Participant()
        participant.full_name = self.request.get('full_name')
        participant.email = self.request.get('email')
        participant.mobile_number = self.request.get('mobile_number')
        participant.phone_number = self.request.get('phone_number')
        participant.pricing = Decimal(self.request.get('pricing'))
        participant.designation = self.request.get('designation')
        participant.department = self.request.get('department')
        participant.organization = self.request.get('organization')
        participant.address = self.request.get('address')
        participant.put()

        queue_mail_task(url='/worker/mail/thanks/registration/',
            params=dict(
                full_name=participant.full_name,
                email = participant.email,
                key=str(participant.key())
            ),
            method='POST'
        )
        self.response.out.write(participant.to_json('full_name', 'is_starred', 'is_deleted', 'is_active'))
Ejemplo n.º 23
0
    def get(self):
        from fee_calculation import calculate_fee
        
        today = datetime.utcnow()
        training_programs = TrainingProgram.get_all_payable_for_date(today.year, today.month, today.day)
        for training_program in training_programs:
            fees = training_program.get_fees_sorted_by_count()
            count = training_program.get_participant_count()
            current_fee = calculate_fee(fees, count)

            logging.info("fees: " + str(fees) + " count: " + str(count) + " current_fee: " + str(current_fee))
            training_program.final_price = current_fee
            training_program.is_payment_mail_queued = True
            training_program.put()

            for registrant in training_program.registrants:
                queue_mail_task(url='/worker/mail/training_announcement_payment_notification/',
                    params=dict(
                        registrant_key=str(registrant.key()),
                        training_program_key=str(training_program.key()),
                        current_fee=current_fee
                    ),
                    method='POST'
                )
Ejemplo n.º 24
0
    def post(self):
        session_user = self.get_session_user()

        first_name = self.request.get('first_name')
        last_name = self.request.get('last_name')
        birthdate_day = dec(self.request.get('birthdate_day'))
        birthdate_month = dec(self.request.get('birthdate_month'))
        birthdate_year = dec(self.request.get('birthdate_year'))
        company = self.request.get('company')
        designation = self.request.get('designation')
        gender = self.request.get('gender')
        t_shirt_size = self.request.get('t_shirt_size')
        email_address = self.request.get('email_address')
        corporate_email_address = self.request.get('corporate_email_address')
        railway_line = self.request.get('railway_line')
        graduation_year = dec(self.request.get('graduation_year'))

        if not session_user.email:
            session_user.email = email_address

        apartment = self.request.get('apartment')
        street_name = self.request.get('street_name')
        landmark = self.request.get('landmark')
        city = self.request.get('city')
        state_province = self.request.get('state_province')
        zip_code = self.request.get('zip_code')
        country = self.request.get('country')

        phone_number_count = int(self.request.get('phone_number_count'), 10)
        phone_numbers = []
        for i in range(1, phone_number_count+1):
            phone_number = self.request.get('phone_number_' + str(i))
            phone_type = self.request.get('phone_type_' + str(i))
            phone_numbers.append((phone_number, phone_type))

        #enable_notifications = True if self.request.get('enable_notifications') else False
        #enable_public_profile = True if self.request.get('enable_public_profile') else False
        #enable_administrator_contact = True if self.request.get('enable_administrator_contact') else False
        enable_notifications = True
        enable_public_profile = True
        enable_administrator_contact = True

        # Create database entries.
        to_store = []
        user = models.User(username=session_user.username,
            email=email_address,
            signin_email=session_user.email,
            identifier=session_user.identifier)
        if corporate_email_address:
            user.corporate_email = corporate_email_address
        user.nickname = first_name + ' ' + last_name
        user.enable_notifications = enable_notifications
        user.enable_public_profile = enable_public_profile
        user.enable_administrator_contact = enable_administrator_contact
        user.wants_activation = True
        user.has_updated_profile = True
        user.auth_provider = session_user.auth_provider
        user.is_active = False
        if session_user.photo:
            user.photo = session_user.photo
            user.gravatar = get_gravatar_url(email_address)
        user.put()

        person = models.Person()
        person.user = user
        person.first_name = first_name
        person.last_name = last_name
        person.company = company
        person.designation = designation
        person.birthdate = datetime(birthdate_year, birthdate_month, birthdate_day).date()
        person.gender = gender
        person.graduation_year = graduation_year
        person.t_shirt_size = t_shirt_size
        person.put()

        host_info = models.UserHostInformation()
        host_info.user = user
        host_info.ip_address = self.request.remote_addr
        host_info.http_user_agent = self.request.headers.get('User-Agent', '')
        host_info.http_accept_language = self.request.headers.get('Accept-Language', '')
        host_info.http_accept_encoding = self.request.headers.get('Accept-Encoding', '')
        host_info.http_accept_charset = self.request.headers.get('Accept-Charset', '')
        host_info.http_accept = self.request.headers.get('Accept', '')
        host_info.http_referer = self.request.headers.get('Referer', '')
        to_store.append(host_info)

        openid = models.OpenID(username=session_user.username)
        openid.nickname = session_user.nickname
        openid.email = session_user.email
        openid.auth_provider = session_user.auth_provider
        openid.identifier = session_user.identifier
        openid.profile_url = session_user.profile_url
        openid.user = user
        openid.is_primary_id = True
        to_store.append(openid)

        address_line = ', '.join([
            apartment,
            street_name,
            landmark,
            '' if railway_line == 'other' else models.RAILWAY_LINES.get(railway_line, '') + ' Railway Line',
            city,
            state_province + ' ' + zip_code,
            COUNTRY_NAME_ISO_ALPHA_3_TABLE.get(country, ''),
            ])
        address = models.PersonAddress(person=person,
            address_line=address_line,
            street_name=street_name,
            zip_code=zip_code,
            state_province=state_province,
            country=country,
            landmark=landmark,
            apartment=apartment,
            city=city,
            nearest_railway_line=railway_line,
            address_type='home')
        to_store.append(address)

        for (number, phone_type) in phone_numbers:
            if number.strip():
                phone = models.PersonPhone(person=person,
                    number=number,
                    phone_type=phone_type)
                to_store.append(phone)

        # Batch write all non-dependent entities.
        db.put(to_store)
        models.User.increment_user_count()
        queue_mail_task(url='/worker/mail/signup_notification/' + str(user.key()), method='GET')
        
        rendered_template = render_template('activation_reminder.html')
        self.response.out.write(rendered_template)