Example #1
0
 def get(self):
     """This function takes two parameters from the given URL: the googler's 
     email and a pseudo-randomly generated token and displays a confirmation 
     message of the activation of the new Spoogler."""
     
     template_context = {'googler': self.request.get('g').strip(),
                         'token': int(self.request.get('t').strip())}
      
     # The status of the Spoogler changes from inactive to active
     spoogler = Spoogler.query(Spoogler.googler_ldap == \
                template_context['googler']).fetch()
     if spoogler:
         if template_context['token'] == spoogler[0].token:
             if spoogler[0].status != 0:
                 template_context['confirmation_message'] = spoogler[0].full_name\
                     + ' is already an active member on this group.'
             else:
                 if self._activate_spoogler(spoogler[0]):
                     template_context['confirmation_message'] = \
                         'Congratulations! ' + spoogler[0].full_name + \
                         ' is now an active member of this group and'\
                         ' has received a Welcome email.'
                     template_context['spoogler_email'] = spoogler[0].spoogler_email
                     ConfirmHandler._send_welcome_email(template_context)
                     # Send a notification to ambassadors:
                     ConfirmHandler._send_notification_email(template_context)
         else:
             template_context['confirmation_message'] = 'Wrong information.'\
                 ' Please contact us: [email protected]'
     else:
         template_context['confirmation_message'] = 'Wrong information.'\
             ' Please contact us: [email protected]'
     
     self.response.out.write(self._render_template('confirmation.html', 
                             template_context))
Example #2
0
    def get(self):
        """Displays the admin form for the ambassadors/admins."""
        template_context = {}
        get_spoogler_context(self.request, template_context)
        # Find the name of the admin that is logged in
        current_user = template_context['user']
        user_email = current_user.email()
        strip_at_index = user_email.find("@")
        template_context['user_name'] = user_email[0:strip_at_index]

        query = Spoogler.query()
        query = query.order(-Spoogler.date_created).order(Spoogler.full_name)
        template_context['query'] = query
        self.update(template_context)
Example #3
0
    def post(self):
        # get context
        template_context = {}
        get_spoogler_context(self.request, template_context)

        # Build query
        query = Spoogler.query()
        query = query.order(-Spoogler.date_created).order(Spoogler.full_name)
        #logging.info(template_context['work_status'])

        # Apply filters
        template_context['query'] = self._apply_filters(
            query, template_context)

        self.update(template_context)
Example #4
0
    def _send_welcome_email(cls, template_context):
        """It sends a Welcome email once the new spoogler has been successfully
        activated by the Googler."""
        message = mail.EmailMessage(sender="""Bay Area Spooglers Webmaster
                                    <*****@*****.**>""")
        spoogler_qry = Spoogler.query(
            Spoogler.spoogler_email ==
            template_context['spoogler_email']).fetch()
        message.to = spoogler_qry[0].spoogler_email
        if spoogler_qry[0].test:
            message.to = "*****@*****.**"
        message.subject = "Welcome to the Bay Area Spooglers Group!"
        message.html = """
        <html><head></head>
          <body>
            <p>Hello %s,</p>

            <p>Welcome to the Bay Area Spooglers Group!</p>

            <p>We are the group ambassadors and are here to help make your
            transition to the Bay Area with your Google spouse/partner easier.</p>

            <p>You will be sent an invitation to our Facebook page
            separately. Please dive right in and join us at any of the events
            we have planned. Don’t be shy - you are not alone! So come along
            and meet other people who have recently arrived and also people
            who have been here a bit longer. We’re a friendly bunch and
            we know just how you feel.</p>

            <p>In the following days, you will receive an invitation to our Google
            group to gain access to our
            <a href="https://sites.google.com/site/bayareagsites/">website</a> and
            <a href="https://sites.google.com/site/bayareagsites/home/events-schedule">
            google calendar</a>.</p>

            <p>We are always looking for new volunteers, so if you are
            interested in assisting the group please get in touch.</p>

            <p>We look forward to meeting you! <br>
            %s and %s.<br>
            <a href="mailto:[email protected]">[email protected]
            </a></p>
          </body>
        </html>
        """ % (str(
            spoogler_qry[0].full_name), admins_list[2][1], admins_list[3][1])
        message.send()
Example #5
0
    def _send_welcome_email(cls, template_context):
        """It sends a Welcome email once the new spoogler has been successfully
        activated by the Googler."""
        message = mail.EmailMessage(sender="""Bay Area Spooglers Webmaster
                                    <*****@*****.**>""")
        spoogler_qry = Spoogler.query(Spoogler.spoogler_email ==
                                      template_context['spoogler_email']).fetch()
        message.to = spoogler_qry[0].spoogler_email
        if spoogler_qry[0].test:
            message.to = "*****@*****.**"
        message.subject = "Welcome to the Bay Area Spooglers Group!"
        message.html = """
        <html><head></head>
          <body>
            <p>Hello %s,</p>

            <p>Welcome to the Bay Area Spooglers Group!</p>

            <p>We are the group ambassadors and are here to help make your
            transition to the Bay Area with your Google spouse/partner easier.</p>

            <p>You will be sent an invitation to our Facebook page
            separately. Please dive right in and join us at any of the events
            we have planned. Don’t be shy - you are not alone! So come along
            and meet other people who have recently arrived and also people
            who have been here a bit longer. We’re a friendly bunch and
            we know just how you feel.</p>

            <p>In the following days, you will receive an invitation to our Google
            group to gain access to our
            <a href="https://sites.google.com/site/bayareagsites/">website</a> and
            <a href="https://sites.google.com/site/bayareagsites/home/events-schedule">
            google calendar</a>.</p>

            <p>We are always looking for new volunteers, so if you are
            interested in assisting the group please get in touch.</p>

            <p>We look forward to meeting you! <br>
            %s and %s.<br>
            <a href="mailto:[email protected]">[email protected]
            </a></p>
          </body>
        </html>
        """ % (str(spoogler_qry[0].full_name), admins_list[2][1], admins_list[3][1])
        message.send()
Example #6
0
    def post(self):
        logging.info(self.request.get("googler_ldap"))
        logging.info(self.request.get("status"))
        googler_ldap = self.request.get("googler_ldap")
        current_user = users.get_current_user()
        spoogler_qry = Spoogler.query(
            Spoogler.googler_ldap == googler_ldap).fetch()
        spoogler = spoogler_qry[0]

        if self.request.get("status") == "true":
            spoogler.on_fb_kids = True
            spoogler.ambassador_fbk = current_user.email()
            spoogler.ambassador_last = current_user.email()
        try:
            spoogler.put()
            self.response.out.write(
                spoogler.full_name +
                ' was registered as part of the Facebook KidsZone group.')
        except datastore_errors.TransactionFailedError:
            self.response.out.write('Error: please try again')
Example #7
0
    def _send_notification_email(cls, template_context):
        """
        Sends a notification email to the ambassador(s) when a new member has
        been confirmed.
        """
        spoogler_qry = Spoogler.query(
            Spoogler.spoogler_email ==
            template_context['spoogler_email']).fetch()
        admin_url = "https://baspooglers.appspot.com/admin"
        sender_address = """Bay Area Spooglers Webmaster
                         <*****@*****.**>"""
        message = mail.EmailMessage(sender=sender_address)
        message.subject = "A new BASpooglers member has been confirmed"

        message.to = admins_list[1][3]

        if spoogler_qry[0].test:
            message.to = "*****@*****.**"
        message.html = """
        <html>
          <head></head>
          <body>
            <p>Dear Ambassadors, </p>

            <p>%s has been confirmed and added as a new member of our Bay Area
            Spooglers group. Please go the Admin page to invite this new member
            to our Google group and Facebook pages:</p>
            <p><a href=%s>Bay Area Spooglers Group Admin page</a></p>

            <p>If you have any questions or concerns, please don't hesitate to
            reach out at:<br>
            <a href="mailto:[email protected]">
            [email protected]</a></p>

            <p>Warmest regards, <br>
            The Bay Area Spooglers Webmaster.</p>
          </body>
        </html>
        """ % (str(spoogler_qry[0].full_name), admin_url)

        message.send()
Example #8
0
    def _send_notification_email(cls, template_context):
        """
        Sends a notification email to the ambassador(s) when a new member has
        been confirmed.
        """
        spoogler_qry = Spoogler.query(Spoogler.spoogler_email ==
                                      template_context['spoogler_email']).fetch()
        admin_url = "https://baspooglers.appspot.com/admin"
        sender_address = """Bay Area Spooglers Webmaster
                         <*****@*****.**>"""
        message = mail.EmailMessage(sender=sender_address)
        message.subject = "A new BASpooglers member has been confirmed"

        message.to = admins_list[1][3]

        if spoogler_qry[0].test:
            message.to = "*****@*****.**"
        message.html = """
        <html>
          <head></head>
          <body>
            <p>Dear Ambassadors, </p>

            <p>%s has been confirmed and added as a new member of our Bay Area
            Spooglers group. Please go the Admin page to invite this new member
            to our Google group and Facebook pages:</p>
            <p><a href=%s>Bay Area Spooglers Group Admin page</a></p>

            <p>If you have any questions or concerns, please don't hesitate to
            reach out at:<br>
            <a href="mailto:[email protected]">
            [email protected]</a></p>

            <p>Warmest regards, <br>
            The Bay Area Spooglers Webmaster.</p>
          </body>
        </html>
        """ % (str(spoogler_qry[0].full_name), admin_url)

        message.send()
Example #9
0
    def get(self):
        """This function takes two parameters from the given URL: the googler's 
        email and a pseudo-randomly generated token and displays a confirmation 
        message of the activation of the new Spoogler."""

        template_context = {
            'googler': self.request.get('g').strip(),
            'token': int(self.request.get('t').strip())
        }

        # The status of the Spoogler changes from inactive to active
        spoogler = Spoogler.query(Spoogler.googler_ldap == \
                   template_context['googler']).fetch()
        if spoogler:
            if template_context['token'] == spoogler[0].token:
                if spoogler[0].status != 0:
                    template_context['confirmation_message'] = spoogler[0].full_name\
                        + ' is already an active member on this group.'
                else:
                    if self._activate_spoogler(spoogler[0]):
                        template_context['confirmation_message'] = \
                            'Congratulations! ' + spoogler[0].full_name + \
                            ' is now an active member of this group and'\
                            ' has received a Welcome email.'
                        template_context['spoogler_email'] = spoogler[
                            0].spoogler_email
                        ConfirmHandler._send_welcome_email(template_context)
                        # Send a notification to ambassadors:
                        ConfirmHandler._send_notification_email(
                            template_context)
            else:
                template_context['confirmation_message'] = 'Wrong information.'\
                    ' Please contact us: [email protected]'
        else:
            template_context['confirmation_message'] = 'Wrong information.'\
                ' Please contact us: [email protected]'

        self.response.out.write(
            self._render_template('confirmation.html', template_context))
Example #10
0
 def _validate_form(cls, template_context):
     """Verifies that the information entered in the form is complete and 
     correct according to the instructions."""
     result = True
     mail_re = re.compile(r'^.+@.+$')
     at_sign_re = re.compile(r'@')
     fb_email_qry = Spoogler.query(Spoogler.spoogler_fb_email ==
                             template_context['spoogler_fb_email']).fetch()
     # Verify that the user entered information in the fields:
     if not template_context['full_name']:
         template_context['full_name_error'] = True
         result = False
     if not template_context['spoogler_email'] or \
        not mail_re.search(template_context['spoogler_email']):
         template_context['spoogler_email_error'] = True
         result = False
     # Check uniqueness of spoogler_email
     if template_context['spoogler_email']:
         spoogler_email_qry = Spoogler.query(Spoogler.spoogler_email ==
                              template_context['spoogler_email']).fetch()
         if spoogler_email_qry:
             template_context['spoogler_email_error'] = True
             template_context['spoogler_email_duplicate'] = True
             result = False
     # Check uniqueness of spoogler_fb_email
     if template_context['spoogler_fb_email']:
         if not mail_re.search(template_context['spoogler_fb_email']):
             template_context['fb_email_error'] = True
             result = False
         if fb_email_qry:
             template_context['fb_email_error'] = True
             template_context['fb_email_duplicate'] = True
             result = False
     if not template_context['googler_ldap']:
         template_context['googler_ldap_error'] = True
         result = False
     # Check that the user entered just the ldap (without the @google.com)
     if at_sign_re.search(template_context['googler_ldap']):
         template_context['ldap_at_sign_error'] = True
         result = False
     # Check uniqueness of googler_ldap
     if template_context['googler_ldap']:
         googler_ldap_qry = Spoogler.query(Spoogler.googler_ldap == \
                            template_context['googler_ldap']).fetch()
         if googler_ldap_qry:
             template_context['googler_ldap_error'] = True
             template_context['googler_ldap_duplicate'] = True
             result = False
     # Check that an option to get in the Facebook KidsZone group is selected
     # Although the final variable will be a bool, we need an integer here
     # The conversion to a bool is done when the Spoogler entity is created below
     if template_context['kidszone_invite'] == 0:
         template_context['kidszone_invite_error'] = True
         result = False
     if template_context['kidszone_invite'] == 1 and \
             not template_context['spoogler_fb_email']:
         template_context['kidszone_invite_error'] = True
         template_context['fb_email_error'] = True
         result = False
     
     return result
Example #11
0
    def _validate_form(cls, template_context):
        """Verifies that the information entered in the form is complete and 
        correct according to the instructions."""
        result = True
        mail_re = re.compile(r'^.+@.+$')
        at_sign_re = re.compile(r'@')
        fb_email_qry = Spoogler.query(
            Spoogler.spoogler_fb_email ==
            template_context['spoogler_fb_email']).fetch()
        # Verify that the user entered information in the fields:
        if not template_context['full_name']:
            template_context['full_name_error'] = True
            result = False
        if not template_context['spoogler_email'] or \
           not mail_re.search(template_context['spoogler_email']):
            template_context['spoogler_email_error'] = True
            result = False
        # Check uniqueness of spoogler_email
        if template_context['spoogler_email']:
            spoogler_email_qry = Spoogler.query(
                Spoogler.spoogler_email ==
                template_context['spoogler_email']).fetch()
            if spoogler_email_qry:
                template_context['spoogler_email_error'] = True
                template_context['spoogler_email_duplicate'] = True
                result = False
        # Check uniqueness of spoogler_fb_email
        if template_context['spoogler_fb_email']:
            if not mail_re.search(template_context['spoogler_fb_email']):
                template_context['fb_email_error'] = True
                result = False
            if fb_email_qry:
                template_context['fb_email_error'] = True
                template_context['fb_email_duplicate'] = True
                result = False
        if not template_context['googler_ldap']:
            template_context['googler_ldap_error'] = True
            result = False
        # Check that the user entered just the ldap (without the @google.com)
        if at_sign_re.search(template_context['googler_ldap']):
            template_context['ldap_at_sign_error'] = True
            result = False
        # Check uniqueness of googler_ldap
        if template_context['googler_ldap']:
            googler_ldap_qry = Spoogler.query(Spoogler.googler_ldap == \
                               template_context['googler_ldap']).fetch()
            if googler_ldap_qry:
                template_context['googler_ldap_error'] = True
                template_context['googler_ldap_duplicate'] = True
                result = False
        # Check that an option to get in the Facebook KidsZone group is selected
        # Although the final variable will be a bool, we need an integer here
        # The conversion to a bool is done when the Spoogler entity is created below
        if template_context['kidszone_invite'] == 0:
            template_context['kidszone_invite_error'] = True
            result = False
        if template_context['kidszone_invite'] == 1 and \
                not template_context['spoogler_fb_email']:
            template_context['kidszone_invite_error'] = True
            template_context['fb_email_error'] = True
            result = False

        return result