Beispiel #1
0
    def post(self):
        """ Get fields from POST dict """

        user_contacinfo = bmodels.ContactInfo.get_by_userkey(self.user_key)
        if not user_contacinfo:
            user_contacinfo = bmodels.ContactInfo()
            user_contacinfo.user = self.user_key

        address1 = self.form.address1.data
        address2 = self.form.address2.data
        city = self.form.city.data
        state = self.form.state.data.upper()
        zipcode = self.form.zipcode.data
        phone = self.form.phone.data

        try:
            message = ''
            user_contacinfo.address1 = address1
            user_contacinfo.address2 = address2
            user_contacinfo.city = city
            user_contacinfo.state = state
            user_contacinfo.zipcode = zipcode
            user_contacinfo.phone = phone

            user_contacinfo.put()
            message += " " + _('Your contact info has been updated.')

            self.add_message(message, 'success')
            self.redirect('/settings/profile')

        except (AttributeError, KeyError, ValueError), e:
            logging.error('Error updating contact info: ' + str(e))
            message = _('Unable to update contact info. Please try again later.')
            self.add_message(message, 'error')
            return self.get()
Beispiel #2
0
    def post(self):
        """ Get fields from POST dict """

        if not self.form.validate():
            return self.get()
        username = self.form.username.data.lower()
        name = self.form.name.data.strip()
        last_name = self.form.last_name.data.strip()
        country = self.form.country.data
        tz = self.form.tz.data

        try:
            user_info = self.user_model.get_by_id(long(self.user_id))

            try:
                message = ''
                # update username if it has changed and it isn't already taken
                if username != user_info.username:
                    user_info.unique_properties = ['username', 'email']
                    uniques = [
                        'User.username:%s' % username,
                        'User.auth_id:own:%s' % username,
                    ]
                    # Create the unique username and auth_id.
                    success, existing = Unique.create_multi(uniques)
                    if success:
                        # free old uniques
                        Unique.delete_multi(
                            ['User.username:%s' % user_info.username, 'User.auth_id:own:%s' % user_info.username])
                        # The unique values were created, so we can save the user.
                        user_info.username = username
                        user_info.auth_ids[0] = 'own:%s' % username
                        message += _('Your new username is <strong>{}</strong>').format(username)

                    else:
                        message += _(
                            'The username <strong>{}</strong> is already taken. Please choose another.').format(
                            username)
                        # At least one of the values is not unique.
                        self.add_message(message, 'error')
                        return self.get()
                user_info.name = name
                user_info.last_name = last_name
                user_info.country = country
                user_info.tz = tz
                user_info.put()
                message += " " + _('Thanks, your settings have been saved.')
                self.add_message(message, 'success')
                return self.get()

            except (AttributeError, KeyError, ValueError), e:
                logging.error('Error updating profile: ' + e)
                message = _('Unable to update profile. Please try again later.')
                self.add_message(message, 'error')
                return self.get()

        except (AttributeError, TypeError), e:
            login_error_message = _('Your session has expired.')
            self.add_message(login_error_message, 'error')
            self.redirect_to('login')
Beispiel #3
0
    def post(self):
        """ Get fields from POST dict """

        checked_genres = self.request.POST.getall('genres')

        pseudonyms = self.request.POST.get('pseudonyms').replace('  ', ' ').replace(' ,', ',').split(',')
        pseudonyms = [i.lstrip().rstrip() for i in pseudonyms]

        # k = models.User.get_by_id(long(self.user_id)).key
        print checked_genres
        print pseudonyms

        author_profile = bmodels.AuthorProfile.get_by_userkey(self.user_key)
        if not author_profile:
            author_profile = bmodels.AuthorProfile()
            author_profile.user = self.user_key

        try:
            message = ''
            author_profile.title = self.request.POST.get('title')
            author_profile.overview = self.request.POST.get('overview').replace('\r\r\n', '\r\n')
            author_profile.freelance = (self.request.POST.get('freelance') == "True")
            author_profile.ghostwrites = (self.request.POST.get('ghostwrites') == "True")
            author_profile.genres = checked_genres
            author_profile.pseudonyms = pseudonyms
            author_profile.put()
            message += " " + _('Your author profile has been updated.')
            self.add_message(message, 'success')
            self.redirect('/settings/profile')

        except (AttributeError, KeyError, ValueError), e:
            logging.error('Error creating/updating author profile: ' + e)
            message = _('Unable to create/update author profile. Please try again later.')
            self.add_message(message, 'error')
            return self.get()
Beispiel #4
0
    def get(self):
        render_notice = lambda values: self.render("noticepage", values)

        successful = self.request.get("successful", None)
        if successful == "1":
            values = {
                    "message": _("You successfully signed in, welcome back!"),
                    "redirect": self.request.get("referer"),
                    }
            return render_notice(values)
        elif successful == "0":
            values = {
                    "message": _("Login failed, invalid password or user doesn't exist, you could try again."),
                    "redirect": self.uri_for("login"),
                    }
            return render_notice(values)
        elif successful == "-1":
            values = {
                    "message": _("The user is valid but not verified,\
                            check your email to find the confirmation link\
                            we sent to you when you registered."),
                    "redirect": None,
                    }
            return render_notice(values)
        else:
            if self.get_current_user() != None:
                values = {
                        "message": _("You've logged in, why do you want to do this again?"),
                        "redirect": self.uri_for("home"),
                        }
                return render_notice(values)
            else:
                values = { "referer": self.request.headers.get("Referer", self.uri_for("home")) }
                self.render("loginpage", values)
Beispiel #5
0
 def _set_fields(self, form):        
     setattr(form, 'email', TextField(_(u'Email'),
                             validators=[validators.Email(message=_(u'Invalid email address.'))],
                             filters=[custom_filters.to_lowercase]           
                         ))
     setattr(form, 'password', PasswordField(_(u'Password')))
     setattr(form, 'remember_me', CustomBooleanField(_(u'Remember Me')))
Beispiel #6
0
def get_all_titles():
    return [
            ("mr", _('Mr.')),
            ("mrs", _('Mrs.')),
            ("ms", _('Ms.')),
            ("dr", _('Dr.')),
            ]
Beispiel #7
0
def send_registration_email(the_req, the_email, the_url, the_locale_override=None):

    set_locale_for_user(the_req, the_locale_override)

    if not mail.is_email_valid(the_email):
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Welcome to Gig-o-Matic')
#     message.body = u"""
# Hello! You have registered to join Gig-o-Matic - click the link below to log in and you're good to go. (The link
# is good for 48 hours - after that you can just register again to get a new one if you need it.)
# 
# {0}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_url)
    message.body=_('welcome_msg_email').format(the_url)
    
    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
Beispiel #8
0
def send_forgot_email(the_req, the_email, the_url):

    set_locale_for_user(the_req)

    if not mail.is_email_valid(the_email):
        logging.error("send_forgot_email invalid email: {0}".format(the_email))
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Gig-o-Matic Password Reset')
#     message.body = u"""
# Hello! To reset your Gig-o-Matic password, click the link below.
# 
# {0}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_url)

    message.body = _('forgot_password_email').format(the_url)

    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
Beispiel #9
0
def send_band_accepted_email(the_req, the_email, the_band):

    set_locale_for_user(the_req)

    if not mail.is_email_valid(the_email):
        return False
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email
    message.subject = _('Gig-o-Matic: Confirmed!')
#     message.body = u"""
# Hello! You have been confirmed as a member of {0} and can now start using Gig-o-Matic to manage your band life.
# 
# http://gig-o-matic.appspot.com/band_info.html?bk={1}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(the_band.name, the_band.key.urlsafe())
    message.body = _('member_confirmed_email').format(the_band.name, the_band.key.urlsafe())

    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True
Beispiel #10
0
def send_the_new_member_email(the_locale, the_email_address, new_member, the_band):

    if not mail.is_email_valid(the_email_address):
        return False
        
    i18n.get_i18n().set_locale(the_locale)
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email_address
    message.subject = _('Gig-o-Matic New Member for band {0})').format(the_band.name)
#     message.body = u"""
# Hello! A new member {0} has signed up for your band {1}. Please log in and
# confirm the membership.
# 
# http://gig-o-matic.appspot.com/band_info.html?bk={2}
# 
# Thanks,
# The Gig-o-Matic Team
# 
#     """.format(new_member.name, the_band.name, the_band.key.urlsafe())
    message.body = _('new_member_email').format(new_member.name, the_band.name, the_band.key.urlsafe())

    try:
        message.send()
    except:
        logging.error('failed to send email!')
        
    return True        
Beispiel #11
0
def send_the_pending_email(the_req, the_email_address, the_confirm_link):
    if not mail.is_email_valid(the_email_address):
        return False
        
    set_locale_for_user(the_req)
        
    message = mail.EmailMessage()
    message.sender = SENDER_EMAIL
    message.to = the_email_address
    message.subject = _('Gig-o-Matic Confirm Email Address')
#     message.body = u"""
# Hi there! Someone has requested to change their Gig-o-Matic ID to this email address.
# If it's you, please click the link to confirm. If not, just ignore this and it will
# go away.
# 
# {0}
# 
# Thanks,
# Team Gig-o-Matic
# 
#     """.format(the_confirm_link)
    message.body=_('confirm_email_address_email').format(the_confirm_link)
    try:
        message.send()
    except:
        logging.error('failed to send email!')

    return True
Beispiel #12
0
    def get(self, user_id, token):
        try:
            if not self.user_model.validate_auth_token(user_id, token):
                message = _('The link is invalid.')
                self.add_message(message, 'danger')
                return self.redirect_to('home')

            user = self.user_model.get_by_id(long(user_id))
            # activate the user's account
            user.activated = True
            user.put()

            # Update all invites that this user's email have been invited to
            UpdateUserOnAttendeesCommand(user).execute()


            # Login User
            self.auth.get_user_by_token(int(user_id), token)

            # Delete token
            self.user_model.delete_auth_token(user_id, token)

            message = _('Congratulations, Your account <strong>{}</strong> has been successfully activated.').format(
                user.username)
            self.add_message(message, 'success')
            self.redirect_to('edit-profile')

        except (AttributeError, KeyError, InvalidAuthIdError, NameError), e:
            logging.error("Error activating an account: %s" % e)
            message = _('Sorry, Some error occurred.')
            self.add_message(message, 'danger')
            return self.redirect_to('home')
Beispiel #13
0
	def get(self, user_id, token):
		try:
			if not models.User.validate_auth_token(user_id, token):
				message = _('The link is invalid.')
				self.add_message(message, 'error')
				return self.redirect_to('home')

			user = models.User.get_by_id(long(user_id))
			# activate the user's account
			user.activated = True
			user.put()

			# Login User
			self.auth.get_user_by_token(int(user_id), token)

			# Delete token
			models.User.delete_auth_token(user_id, token)

			message = _('Congratulations, Your account %s has been successfully activated.'
						% '<strong>{0:>s}</strong>'.format(user.username) )
			self.add_message(message, 'success')
			self.redirect_to('home')

		except (AttributeError, KeyError, InvalidAuthIdError, NameError), e:
			logging.error("Error activating an account: %s" % e)
			message = _('Sorry, Some error occurred.')
			self.add_message(message, 'error')
			return self.redirect_to('home')
Beispiel #14
0
    def post(self):
        """ Get fields from POST dict """                        
        
        try:
            if self.request.get('shaper_id') == "none":
                shaper = models.Shapers()
            else:
                shaper = models.Shapers.get_by_id(long(self.request.get('shaper_id')))
                if shaper is None:
                    shaper = models.Shapers()

            shaper.name = self.request.get('name')
            shaper.email = self.request.get('email')
            birth = self.request.get('birth')
            if (len(birth) > 9):
                shaper.birth = date(int(birth[:4]), int(birth[5:7]), int(birth[8:]))
            shaper.bio = self.request.get('bio')
            shaper.twitter = self.request.get('twitter')
            shaper.linkedin = self.request.get('linkedin')
            shaper.image = self.request.get('image')
            shaper.put()
            
            message = _(messages.saving_success)
            self.add_message(message, 'success')
            return self.redirect_to('admin-shapers')


        except Exception as e:
            logging.info('error in post: %s' % e)
            message = _(messages.saving_error)
            self.add_message(message, 'danger')
            return self.get()
Beispiel #15
0
    def get(self, provider_name):
        provider = self.provider_info[provider_name]

        if not self.app.config.get('enable_federated_login'):
            message = _('Federated login is disabled.')
            self.add_message(message, 'warning')
            return self.redirect_to('login')
        callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)

        if provider_name == "facebook":
            self.session['linkedin'] = None
            perms = ['email', 'publish_actions']
            fb_url = facebook.auth_url(self.app.config.get('fb_api_key'), callback_url, perms)
            logging.info(fb_url)
            self.redirect(fb_url)

        elif provider_name == "google":

            user = users.get_current_user()
            continue_url = self.request.get('continue_url')
            dest_url = dest_url = self.uri_for('social-login-complete', provider_name=provider_name)
            if continue_url:
                dest_url = self.uri_for('social-login-complete', provider_name=provider_name, continue_url=continue_url)

            if user:
                self.redirect(dest_url)
            else:
                self.redirect(users.create_login_url(dest_url))
        else:
            message = _('%s authentication is not yet implemented.' % provider.get('label'))
            self.add_message(message, 'warning')
            self.redirect_to('login')
Beispiel #16
0
    def post(self):
        """
              validate contact form
        """
        if not self.form.validate():
            return self.get()
        remoteip  = self.request.remote_addr
        user_agent  = self.request.user_agent
        name = self.form.name.data.strip()
        email = self.form.email.data.lower()
        message = self.form.message.data.strip()

        try:
            subject = _("Contact")
            body = """
            IP Address : %s
            Web Browser  : %s

            Sender : %s <%s>
            %s
            """ % (remoteip, user_agent, name, email, message)

            utils.send_email(config.contact_recipient, subject, body)

            message = _('Message sent successfully.')
            self.add_message(message, 'success')
            return self.redirect_to('contact')

        except (AttributeError, KeyError), e:
            message = _('Error sending the message. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('contact')
Beispiel #17
0
    def get(self):
        params = {}
        target_user_id = int(self.request.get('user_id', '0'))
        if not target_user_id:
            message = _('User id unavailable. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('show-listings')
        if int(self.user_id) == target_user_id:
            # Viewing logged-in user's profile. Go to profile edit page instead.
            return self.redirect_to('edit-profile')
        u = self.user_model.get_by_id(target_user_id)
        if not u:
            message = _('Could not find user. Please try again later.')
            self.add_message(message, 'error')
            return self.redirect_to('show-listings')
        params['target_user'] = u

        # Check our profile for completeness.
        me = self.user_model.get_by_id(long(self.user_id))
        if ((me.get_full_name == '[Anonymous user]') or
            not me.city or not me.state):
            warning_msg = 'Please <a href="/settings/profile">complete your profile</a>, so that others can see where you\'re coming from, and what you need/have for the event.'
            self.add_message(warning_msg, 'error')
            return self.redirect_to('edit-profile')
        return self.render_template('share_detail.html', **params)
Beispiel #18
0
 def _post(self):
     username = self.request.get("username")
     email = self.request.get("email")
     model = UserModel(verified=False)
     model.assign(self)
     if model.validate():
         if config.get_config("user_email_confirm") == "yes":
             model.put()
             user_confirm.send_confirmation_mail(username, email)
             values = {
                     "message": _(u"""An email that contains the link to activate the account \
                         has been sent to the email"""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
         else:
             model.verified = True
             user_key = model.put()
             rbac.add_role(user_key, rbac.default_role("registered"))
             values = {
                     "message": _(u"""Successfully registered."""),
                     "redirect": None,
                     }
             return self.render("noticepage", values)
     else:
         values = {
                 "model": model
                 }
         return self.render("admin_user_add", values)
    def get(self, token_id):
        # Session request handler
        current_session = Session(self)
        JINJA_ENVIRONMENT.globals['session'] = current_session
        # Language request handler
        Language.language(self)
        # Load jinja template
        template = JINJA_ENVIRONMENT.get_template('static/templates/activation.html')

        # Check if token is expired
        token = database.TokenManager.select_token_by_id(int(token_id))
        if token and (datetime.datetime.now() - datetime.timedelta(days=1) < token.date) and (not token.used):
            # Activate user
            user = token.user.get()
            # Check if user is already activated
            if user.role_level > 0:
                errorMessage = _("AccountAlreadyActivated")
            else:
                errorMessage = None
            database.UserManager.modify_user(user.key, role_level=1)
            # Set token as used
            database.TokenManager.set_used_token(token.key)
        else:
            errorMessage = _("ExpiredTokenOrNotExist")
        # Prompt activation result
        self.response.write(template.render(error=errorMessage))
Beispiel #20
0
 def _set_fields(self, form):
     setattr(form, 'email',TextField(_(u'E-mail Address'), [validators.Email(message=_(u'Invalid email address.'))]))
     if self.get_provider_services():
         setattr(form, 'service', SelectField(_(u'Service'), choices=self.get_provider_services()))
     setattr(form, 'comments', TextAreaField(_(u'Comments for your appointment')))
     setattr(form, 'booking_date', HiddenField('booking_date'))
     setattr(form, 'booking_time', HiddenField('booking_time'))
    def get(self, provider_name):
        provider_display_name = models.SocialUser.PROVIDERS_INFO[provider_name]['label']
        if not config.enable_federated_login:
            message = _('Federated login is disabled.')
            self.add_message(message, 'warning')
            return self.redirect_to('login')

        #OAuth Shizzle    
        callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)
        
        # twitter madness (seriously, what's the deal with them?)
        if provider_name == "twitter":
            twitter_helper = twitter.TwitterAuth(self, redirect_uri=callback_url)
            self.redirect( twitter_helper.auth_url() )

        # github stores the callback URL in the app settings on their site, so we don't pass it here
        # you can register a new app at https://github.com/settings/applications/
        elif provider_name == "github":
            scope = 'gist'
            github_helper = github.GithubAuth(scope)
            self.redirect( github_helper.get_authorize_url() )

        else:
            message = _('%s authentication is not yet implemented.' % provider_display_name)
            self.add_message(message, 'warning')
            self.redirect_to('edit-profile')
Beispiel #22
0
	def get(self, urlsafeCartKey):
		try:
			cart = ndb.Key(urlsafe=urlsafeCartKey).get()
			if cart:
				if cart.d: self.forkCart_form.description.data = cart.d
				if cart.cat: self.forkCart_form.category.data = cart.cat

				params = {
					"forkCartForm" : self.forkCart_form, \
					"cartDetailsForm" : self.cartDetails_form, \
					"urlsafeCartKey": urlsafeCartKey, \
					"cart": cart, \
					}
				self.bournee_template('forkCartForm.html', **params)
			else:
				logging.error("Could not find cart in function GET of class MakeCartPublicFormHandler")
				message = _('There was an Error fetching the cart data. We can not complete request at this time. Please try again later')
				self.add_message(message, 'error')
				try:
					self.redirect(self.request.referer)
				except:
					self.redirect_to('home')
		except Exception as e:
			logging.error("Error occurred running function GET of class MakeCartPublicFormHandler: -- %s" % str(e))
			message = _('There was an Error on the servers. We can not complete request at this time. Please try again later')
			self.add_message(message, 'error')
			try:
				self.redirect(self.request.referer)
			except:
				self.redirect_to('home')
    def get(self, provider_name):
        provider_display_name = models.SocialUser.PROVIDERS_INFO[provider_name]['label']
        if not config.enable_federated_login:
            message = _('Federated login is disabled.')
            self.add_message(message,'warning')
            return self.redirect_to('login')
        callback_url = "%s/social_login/%s/complete" % (self.request.host_url, provider_name)
        if provider_name == "twitter":
            twitter_helper = twitter.TwitterAuth(self, redirect_uri=callback_url)
            self.redirect(twitter_helper.auth_url())
        if provider_name == "facebook":
			fb = facebook.Facebook(config._FbApiKey, config._FbSecret)
			#~ print "HTTP/1.1\n"
			#~ print fb.get_authorize_url('http://localhost:9090')
			#~ return 
			print fb.get_ext_perm_url('')
			print fb.login('')
			return
			fb.auth.createToken()
			fb.login(popup=True)
			#~ print fb.get_add_url('http://localhost') 
        else:
            message = _('%s authentication is not implemented yet.') % provider_display_name
            self.add_message(message,'warning')
            self.redirect_to('edit-profile')
Beispiel #24
0
    def validate_field(self, number):
        if not number:
            return super(CnpjField, self).validate_field(number)

        number = self.normalize_field(number)

        if len(number) != 14:
            return _('CNPJ must have exactly 14 characters')

        try:
            int(number)
        except:
            return _('CNPJ must contain only numbers')

        first_weights = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
        second_weights = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
        first_part = number[:12]

        first_digit = number[12]
        second_digit = number[13]

        if (first_digit == self.__check_digit(first_part, first_weights) and
           second_digit == self.__check_digit(number[:13], second_weights)):
            return None
        else:
            return _('Invalid CNPJ')
Beispiel #25
0
def email_booking_to_patient(handler, booking, activation_url=None):
    ''' send booking info to patient, provider and us '''
    patient = booking.patient.get()
    provider = booking.provider.get()
    to_address = patient.email
    # check email valid
    if not mail.is_email_valid(to_address):
        logging.warn('Email is not valid: %s -- trying anyway...' % to_address)
        
    # create message
    message = mail.EmailMessage()
    message.sender = "Veosan" + ' <' + VEOSAN_SUPPORT_ADDRESS + '>'
    message.to = to_address
    category_label = dict(util.get_all_categories_all_domains())[provider.category]
    message.subject = '%s - %s' % (_(u'Veosan Appointment'), _(category_label).capitalize())
    
    kw = {'booking': booking, 'activation_url': activation_url}
    logging.debug('activation url for email: %s' % activation_url)
    message.body = render_booking_email_body(handler.jinja2, 'email/patient_booking.txt', **kw)
    
    try:
        logging.info('Sending booking email to provider %s' % patient.email)
        message.send()
        
        booking.email_sent_to_patient = True
        booking.put()
    except Exception as e:
        logging.error('Email to patient not sent. %s' % e)
Beispiel #26
0
def get_all_note_types():
    return [('call', _(u'Call')),
            ('email', _(u'Email')),
            ('meeting', _(u'Meeting')),
            ('info', _(u'Info')),
            ('admin', _(u'Admin')),
            ]
Beispiel #27
0
    def post(self):
        """ Get fields from POST dict """

        manuscript_id = self.request.POST.get('manuscript_id')
        manuscript = bmodels.Manuscript.get_by_id(long(manuscript_id))
        upload_full_manuscript = self.get_uploads()

        if upload_full_manuscript:
            try:
                blobstore.delete(manuscript.full_manuscript_key)
            except:
                pass
            full_manuscript_key = upload_full_manuscript[0].key()
            full_manuscript_filename = upload_full_manuscript[0].filename
            full_manuscript_uploaded_on = datetime.now()
        else:
            full_manuscript_key = None

        pprint(upload_full_manuscript[0].__dict__)
        print upload_full_manuscript[0].filename
        print full_manuscript_key

        try:
            message = ''
            manuscript.full_manuscript_key = full_manuscript_key
            manuscript.full_manuscript_filename = full_manuscript_filename
            manuscript.full_manuscript_uploaded_on = full_manuscript_uploaded_on
            manuscript.put()
            message += " " + _('Full manuscript successfully uploaded.')
            self.add_message(message, 'success')

        except (AttributeError, KeyError, ValueError), e:
            logging.error('Error creating/updating manuscript: ' + e)
            message = _('Unable to create/update manuscript. Please try again later.')
            self.add_message(message, 'error')
Beispiel #28
0
    def post(self, **kwargs):
        challenge = self.request.POST.get('recaptcha_challenge_field')
        response = self.request.POST.get('recaptcha_response_field')
        remote_ip = self.request.remote_addr

        cResponse = captcha.submit(
            challenge,
            response,
            self.app.config.get('captcha_private_key'),
            remote_ip)

        if cResponse.is_valid:
            # captcha was valid... carry on..nothing to see here
            pass
        else:
            _message = _('Wrong image verification code. Please try again.')
            self.add_message(_message, 'error')
            return self.redirect_to('delete-account')

        if not self.form.validate() and False:
            return self.get()
        password = self.form.password.data.strip()

        try:

            user_info = self.user_model.get_by_id(long(self.user_id))
            auth_id = "own:%s" % user_info.username
            password = utils.hashing(password, self.app.config.get('salt'))

            try:
                # authenticate user by its password
                user = self.user_model.get_by_auth_password(auth_id, password)
                if user:
                    # Delete Social Login
                    for social in models_boilerplate.SocialUser.get_by_user(user_info.key):
                        social.key.delete()

                    user_info.key.delete()

                    ndb.Key("Unique", "User.username:%s" % user.username).delete_async()
                    ndb.Key("Unique", "User.auth_id:own:%s" % user.username).delete_async()
                    ndb.Key("Unique", "User.email:%s" % user.email).delete_async()

                    #TODO: Delete UserToken objects

                    self.auth.unset_session()

                    # display successful message
                    msg = _("The account has been successfully deleted.")
                    self.add_message(msg, 'success')
                    return self.redirect_to('home')


            except (InvalidAuthIdError, InvalidPasswordError), e:
                # Returns error message to self.response.write in
                # the BaseHandler.dispatcher
                message = _("Incorrect password! Please enter your current password to change your account settings.")
                self.add_message(message, 'error')
            return self.redirect_to('delete-account')
Beispiel #29
0
def send_the_new_member_email(the_locale, the_email_address, new_member, the_band):

    i18n.get_i18n().set_locale(the_locale)

    return _send_admin_mail(the_email_address,
                            _('Gig-o-Matic New Member for band {0}').format(the_band.name),
                            _('new_member_email').format('{0} ({1})'.format(new_member.name, new_member.email_address),
                                                        the_band.name, the_band.key.urlsafe()))
Beispiel #30
0
def install_rbac_default():
    rbac.default_role("super_admin", _(u"Super Admin"))
    guest = rbac.default_role("guest", _(u"Guest"))
    registered = rbac.default_role("registered", _(u"Registered User"), parents=[guest])
    admin = rbac.default_role("admin", _(u"Admin"), parents=[registered])
    rbac.allow(guest, ["view_post"])
    rbac.allow(registered, ["edit_own_post"])
    rbac.allow(admin, ["access_acp", "manage_user", "manage_post"])
Beispiel #31
0
def SEND_EMAIL_LOGIN_ATTEMPT_WITH_YOUR_EMAIL_NO_PW_BODY(link, email):
    return _(
        "An attempt was made to log in to your account using this email address. If you'd like to use your email to log in, you need to set a password for it: %(link)s (click or copy and paste in your browser)",
        link=link,
        email=email)
Beispiel #32
0
def SEND_EMAIL_REGISTER_ATTEMPT_WITH_YOUR_EMAIL_SUBJECT():
    return _("Attempt to register with your email")
Beispiel #33
0
def SEND_EMAIL_REGISTER_ATTEMPT_WITH_YOUR_EMAIL_BODY(link, email):
    return _(
        "An attempt was made to sign up to your account. If you've forgotten your password, you can reset it: %(link)s (click or copy and paste in your browser)",
        link=link,
        email=email)
Beispiel #34
0
def SEND_EMAIL_REGISTER_CONFIRM_SUBJECT():
    return _("Registration confirmation")
Beispiel #35
0
def SEND_EMAIL_REGISTER_CONFIRM_BODY(link):
    return _(
        "Follow this link to confirm your registration: %(link)s (click or copy and paste in your browser)",
        link=link)
Beispiel #36
0
def SEND_EMAIL_PASSWORD_RESET_SUBJECT():
    return _("Password reset")
Beispiel #37
0
def SEND_EMAIL_EMAIL_CHANGE_CONFIRM_BODY(link, email):
    return _(
        "A request to change the email address linked to your account was made. Follow this link to confirm the change to address %(email)s: %(link)s (click or copy and paste in your browser)",
        email=email,
        link=link)
Beispiel #38
0
def DISPLAY_NAME_DELETED_DISPLAY():
    return _("[Deleted user]")
Beispiel #39
0
def REAUTHENTICATED():
    return _("You are reauthenticated.")
Beispiel #40
0
def WRONG_PW():
    return _("Invalid password.")
Beispiel #41
0
def LOGGED_IN():
    return _("You are logged in.")
Beispiel #42
0
def REAUTHENTICATION_NEEDED():
    return _("Please reauthenticate yourself to continue.")
Beispiel #43
0
def SEND_EMAIL_EMAIL_CHANGE_UNDO_SUBJECT():
    return _("Undo change email")
Beispiel #44
0
def SEND_EMAIL_LOGIN_ATTEMPT_WITH_YOUR_EMAIL_NO_PW_SUBJECT():
    return _("Attempt to log in with your email")
Beispiel #45
0
def SEND_EMAIL_EMAIL_CHANGE_CONFIRM_SUBJECT():
    return _("Confirm new email")
Beispiel #46
0
def SEND_EMAIL_EMAIL_CHANGE_UNDO_BODY(link, email):
    return _(
        "A request to change the email address linked to your account was made. Follow this link to cancel the change and ensure the current address %(email)s remains linked to your account: %(link)s (click or copy and paste in your browser)",
        email=email,
        link=link)
Beispiel #47
0
def CURRENT_EMAIL():
    return _("This is your current email.")
Beispiel #48
0
def CANNOT_DELETE_EMAIL():
    return _(
        "You cannot delete your email address: you need an email address to connect to your account."
    )
Beispiel #49
0
def FAIL_REGISTRATION():
    return _("User creation failed, please retry.")
Beispiel #50
0
def LOGIN_NEEDED():
    return _("Please log in to access the page you requested.")
Beispiel #51
0
def MISSING_PW():
    return _("A password is needed.")
Beispiel #52
0
def MISSING_NEW_PW():
    return _("Please enter your new password.")
Beispiel #53
0
def WRONG_EMAIL_FORMAT():
    return _("Invalid email address format.")
Beispiel #54
0
def MISSING_EMAIL():
    return _("An email address is needed.")
Beispiel #55
0
def SEND_EMAIL_ACCOUT_DELETE_SUBJECT():
    return _("Account deletion")
Beispiel #56
0
def TIMEOUT(timeout):
    return _("Timeout. Please wait %(timeout)s before you try again.",
             timeout=timeout)
Beispiel #57
0
def SEND_EMAIL_ACCOUT_POSTS_DELETE_SUBJECT():
    return _("Account and forum posts deletion")
Beispiel #58
0
def SEND_EMAIL_ACCOUT_POSTS_DELETE_BODY(link):
    return _(
        "A request to delete your account and your forum posts was made. Follow this link to confirm deletion - WARNING: this cannot be undone! - %(link)s (click or copy and paste in your browser)",
        link=link)
Beispiel #59
0
def SEND_EMAIL_PASSWORD_RESET_BODY(link):
    return _(
        "A request to reset your password was made. Follow this link to reset your password and set a new one: %(link)s (click or copy and paste in your browser)",
        link=link)
Beispiel #60
0
def WRONG_EMAIL_OR_PW():
    return _("Wrong email or password.")