Beispiel #1
0
    def post(self):
        email = self.request.get('email')
        name = self.request.get('name')
        password = self.request.get('password')

        user_data = member.create_new_member(email=email, name=name, password=password)
        if not user_data[0]: #user_data is a tuple
            self._serve_page(self,failed=True)
            return
        
        user = user_data[1]
        user_id = user.get_id()

        locale = self.request.get('locale','en')
        user.preferences.locale=locale
        user.put()

        token = self.user_model.create_signup_token(user_id)

        verification_url = self.uri_for('verification', type='v', user_id=user_id,
            signup_token=token, _full=True)

        if not ENABLE_EMAIL:
            msg=verification_url
        else:
            goemail.send_registration_email(the_req=self, the_email=email, the_url=verification_url)
            msg=''

        params = {
            'msg': msg,
            'locale': locale
        }
        self.render_template('confirm_signup.html', params=params)
Beispiel #2
0
    def post(self):
        email = self.request.get('email').lower()
        name = self.request.get('name')
        password = self.request.get('password')

        # first check the captcha
        captcha_token = self.request.get('g-recaptcha-response')
        if captcha_token:
            captcha_info = captcha_db.get_captchakeys()
            verify_data = {
                'secret': captcha_info.secret_key,
                'response': captcha_token,
                'remoteip': self.request.host
            }
            response = json.loads(
                urllib2.urlopen(
                    "https://www.google.com/recaptcha/api/siteverify",
                    data=urllib.urlencode(verify_data)).read())
            if not (response['success']
                    and response['score'] > captcha_info.threshold):
                return self._serve_page(_('Please Try Again'))
        else:
            return self._serve_page(_('Please Try Again'))

        try:
            (success, result) = member.create_new_member(email=email,
                                                         name=name,
                                                         password=password)
        except member.MemberError as e:
            return self._serve_page(e.value)

        if not success:
            return self._serve_page(
                _('User could not be created (email address may be in use)'))

        user = result
        user_id = user.get_id()

        locale = self.request.get('locale', 'en')
        user.preferences.locale = locale
        user.put()

        token = self.user_model.create_signup_token(user_id)

        verification_url = self.uri_for('verification',
                                        type='v',
                                        user_id=user_id,
                                        signup_token=token,
                                        _full=True)

        if not ENABLE_EMAIL:
            msg = verification_url
        else:
            goemail.send_registration_email(the_email=email,
                                            the_url=verification_url)
            msg = ''

        params = {'msg': msg, 'locale': locale}
        self.render_template('confirm_signup.html', params=params)
Beispiel #3
0
    def _create_test_band_with_member(self, member_is_admin = True):
        the_band = band.new_band(self.TEST_BAND)
        (member_created, the_member) = member.create_new_member(self.TEST_RECIPIENT, 'Alice', 'password')
        self.assertTrue(member_created)

        membership = assoc.Assoc();
        membership.band = the_band.key
        membership.member = the_member.key
        if member_is_admin:
            membership.is_band_admin = True
        membership.put()

        return (the_band, the_member)
Beispiel #4
0
    def post(self):
        email = self.request.get('email').lower()
        name = self.request.get('name')
        password = self.request.get('password')

        try:
            (success, result) = member.create_new_member(email=email,
                                                         name=name,
                                                         password=password)
        except member.MemberError as e:
            return self._serve_page(e.value)

        if not success:
            return self._serve_page(
                _('User could not be created (email address may be in use)'))

        user = result
        user_id = user.get_id()

        locale = self.request.get('locale', 'en')
        user.preferences.locale = locale
        user.put()

        token = self.user_model.create_signup_token(user_id)

        verification_url = self.uri_for('verification',
                                        type='v',
                                        user_id=user_id,
                                        signup_token=token,
                                        _full=True)

        if not ENABLE_EMAIL:
            msg = verification_url
        else:
            goemail.send_registration_email(the_email=email,
                                            the_url=verification_url)
            msg = ''

        params = {'msg': msg, 'locale': locale}
        self.render_template('confirm_signup.html', params=params)
Beispiel #5
0
    def post(self):
        email = self.request.get('email').lower()
        name = self.request.get('name')
        password = self.request.get('password')

        try:
            (success, result) = member.create_new_member(email=email, name=name, password=password)
        except member.MemberError as e:
            return self._serve_page(e.value)

        if not success:
            return self._serve_page(_('User could not be created (email address may be in use)'))

        user = result
        user_id = user.get_id()

        locale = self.request.get('locale','en')
        user.preferences.locale=locale
        user.put()

        token = self.user_model.create_signup_token(user_id)

        verification_url = self.uri_for('verification', type='v', user_id=user_id,
            signup_token=token, _full=True)

        if not ENABLE_EMAIL:
            msg=verification_url
        else:
            goemail.send_registration_email(the_email=email, the_url=verification_url)
            msg=''

        params = {
            'msg': msg,
            'locale': locale
        }
        self.render_template('confirm_signup.html', params=params)
Beispiel #6
0
    def post(self):
        the_user = self.user
        the_band_keyurl = self.request.get('bk', '0')

        if the_band_keyurl == '0':
            return  # todo figure out what to do

        the_band_key = band.band_key_from_urlsafe(the_band_keyurl)
        the_band = band.get_band(the_band_key)

        out = ''
        if not assoc.get_admin_status_for_member_for_band_key(
                the_user, the_band_key) and not the_user.is_superuser:
            out = 'not admin'

        the_email_blob = self.request.get('e', '')

        # remove commas and stuff
        the_email_blob = the_email_blob.replace(',', ' ')
        the_email_blob = the_email_blob.replace('\n', ' ')
        the_emails = the_email_blob.split(' ')

        ok_email = []
        not_ok_email = []
        for e in the_emails:
            if e:
                e = e.lower()
                if goemail.validate_email(e):
                    ok_email.append(e)
                else:
                    not_ok_email.append(e)

        # ok, now we have a list of good email addresses (or, at least, well-formed email addresses
        # for each one, create a new member (if there isn't one already)
        for e in ok_email:
            existing_member = member.get_member_from_email(e)
            # logging.info("existing_member:{0}".format(existing_member))

            if existing_member:
                # make sure this person isn't already a member of this band; if not, send invite
                if not assoc.get_associated_status_for_member_for_band_key(
                        existing_member, the_band_key):
                    # create assoc for this member - they're already on the gig-o
                    # send email letting them know they're in the band
                    assoc.new_association(existing_member,
                                          the_band,
                                          confirm=True)
                    goemail.send_new_band_via_invite_email(
                        the_band, existing_member, the_band.new_member_message)
            else:
                # create assoc for this member - but because they're not verified, will just show up as 'invited'
                # logging.info("creating new member")
                user_data = member.create_new_member(email=e,
                                                     name='',
                                                     password='******')
                # logging.info("creating new member: {0}".format(user_data))
                the_user = user_data[1]
                if the_user:
                    assoc.new_association(the_user,
                                          the_band,
                                          confirm=True,
                                          invited=True)
                    # send email inviting them to the gig-o
                    token = self.user_model.create_invite_token(
                        the_user.get_id())
                    verification_url = self.uri_for('inviteverification',
                                                    type='i',
                                                    user_id=the_user.get_id(),
                                                    signup_token=token,
                                                    _full=True)

                    goemail.send_gigo_invite_email(the_band, the_user,
                                                   verification_url)

                    # set the new users's locale to be the same as mine by default.
                    if the_user.preferences.locale != self.user.preferences.locale:
                        the_user.preferences.locale = self.user.preferences.locale
                        the_user.put()
                else:
                    logging.error(
                        "Tried to create new invited member, but failed!")

        template_args = {
            'the_band_keyurl': the_band_keyurl,
            'the_ok': ok_email,
            'the_not_ok': not_ok_email
        }
        self.render_template('band_invite_result.html', template_args)
Beispiel #7
0
    def post(self):
        the_user = self.user
        the_band_keyurl=self.request.get('bk','0')

        if the_band_keyurl=='0':
            return # todo figure out what to do

        the_band_key = band.band_key_from_urlsafe(the_band_keyurl)
        the_band = band.get_band(the_band_key)

        out=''
        if not assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) and not the_user.is_superuser:
            out='not admin'
                    
        the_email_blob = self.request.get('e','')    

        # remove commas and stuff
        the_email_blob = the_email_blob.replace(',',' ')
        the_email_blob = the_email_blob.replace('\n',' ')
        the_emails = the_email_blob.split(' ')
        
        ok_email = []
        not_ok_email = []
        for e in the_emails:
            if e:
                e=e.lower()
                if goemail.validate_email(e):
                    ok_email.append(e)
                else:
                    not_ok_email.append(e)
                    
        # ok, now we have a list of good email addresses (or, at least, well-formed email addresses
        # for each one, create a new member (if there isn't one already)
        for e in ok_email:
            existing_member = member.get_member_from_email(e)
            # logging.info("existing_member:{0}".format(existing_member))

            if existing_member:
                # make sure this person isn't already a member of this band; if not, send invite
                if not assoc.get_associated_status_for_member_for_band_key(existing_member, the_band_key):
                    # create assoc for this member - they're already on the gig-o
                    # send email letting them know they're in the band
                    assoc.new_association(existing_member, the_band, confirm=True)
                    goemail.send_new_band_via_invite_email(the_band, existing_member, the_band.new_member_message)
            else:
                # create assoc for this member - but because they're not verified, will just show up as 'invited'
                # logging.info("creating new member")
                user_data = member.create_new_member(email=e, name='', password='******')
                # logging.info("creating new member: {0}".format(user_data))
                the_user = user_data[1]
                if the_user:
                    assoc.new_association(the_user, the_band, confirm=True, invited=True)
                    # send email inviting them to the gig-o
                    token = self.user_model.create_invite_token(the_user.get_id())
                    verification_url = self.uri_for('inviteverification', type='i', user_id=the_user.get_id(),
                        signup_token=token, _full=True)  
                        
                    goemail.send_gigo_invite_email(the_band, the_user, verification_url)                

                    # set the new users's locale to be the same as mine by default.
                    if the_user.preferences.locale != self.user.preferences.locale:
                        the_user.preferences.locale = self.user.preferences.locale
                        the_user.put()
                else:
                    logging.error("Tried to create new invited member, but failed!")
                
        template_args = {
            'the_band_keyurl' : the_band_keyurl,
            'the_ok' : ok_email,
            'the_not_ok' : not_ok_email
        }
        self.render_template('band_invite_result.html', template_args)