Beispiel #1
0
def signin_user_db(user_db):
  if not user_db:
    return flask.redirect(flask.url_for('signin'))
  flask_user_db = FlaskUser(user_db)
  if login.login_user(flask_user_db):
    flask.flash(__('Hello %(name)s, welcome to %(brand)s!!!',
        name=user_db.name, brand=config.CONFIG_DB.brand_name,
      ), category='success')
    response = flask.redirect(util.get_next_url())
    util.set_locale(user_db.locale, response)
    return response
  else:
    flask.flash(__('Sorry, but you could not sign in.'), category='danger')
    return flask.redirect(flask.url_for('signin'))
Beispiel #2
0
def search():
    app.logger.debug("Entered /search")
    #query = request.args.get('q', '')
    if query is None:
        app.logger.debug("Empty search query")
        flash(__("No search terms were specified"), 'error')
        if request.referrer:
            return redirect(request.referrer)
        else:
            return redirect(url_for('index'))
    else:
        query = query.strip()
        app.logger.debug("Searching for '{}'".format(query))
        flash(__("Search results for '{}'").format(query), 'success')
Beispiel #3
0
def prevalidate_user(user):
    token = Token(user.id, generate_token())
    db.session.add(token)
    db.session.commit()
    mail_user(
            user,
            __("[Inkscape.org] Complete Your Registration"),
            __("""Please complete your registration by clicking the link below.

            http://inkscape.org/user/validate/{}/{}

            Thank you,
            The Inkscape Web Team""").format(user.email, token),
            )
Beispiel #4
0
def feedback():
    if not config.CONFIG_DB.feedback_email:
        return flask.abort(418)

    form = FeedbackForm()
    if form.validate_on_submit():
        mail.send_mail(sender=config.CONFIG_DB.feedback_email,
                       to=config.CONFIG_DB.feedback_email,
                       subject='[%s] %s' % (
                           config.CONFIG_DB.brand_name,
                           form.subject.data,
                       ),
                       reply_to=form.email.data
                       or config.CONFIG_DB.feedback_email,
                       body='%s\n\n%s' % (form.message.data, form.email.data))
        flask.flash(__('Thank you for your feedback!'), category='success')
        return flask.redirect(flask.url_for('welcome'))
    if not form.errors and auth.current_user_id() > 0:
        form.email.data = auth.current_user_db().email

    return flask.render_template(
        'feedback.html',
        title=_('Feedback'),
        html_class='feedback',
        form=form,
    )
Beispiel #5
0
def feedback():
  if not config.CONFIG_DB.feedback_email:
    return flask.abort(418)

  form = FeedbackForm()
  if form.validate_on_submit():
    mail.send_mail(
        sender=config.CONFIG_DB.feedback_email,
        to=config.CONFIG_DB.feedback_email,
        subject='[%s] %s' % (
            config.CONFIG_DB.brand_name,
            form.subject.data,
          ),
        reply_to=form.email.data or config.CONFIG_DB.feedback_email,
        body='%s\n\n%s' % (form.message.data, form.email.data)
      )
    flask.flash(__('Thank you for your feedback!'), category='success')
    return flask.redirect(flask.url_for('welcome'))
  if not form.errors and auth.current_user_id() > 0:
    form.email.data = auth.current_user_db().email

  return flask.render_template(
      'feedback.html',
      title=_('Feedback'),
      html_class='feedback',
      form=form,
    )
Beispiel #6
0
def google_authorized():
    google_user = users.get_current_user()
    if google_user is None:
        flask.flash(__('You denied the request to sign in.'))
        return flask.redirect(util.get_next_url())

    user_db = retrieve_user_from_google(google_user)
    return signin_user_db(user_db)
Beispiel #7
0
def google_authorized():
  google_user = users.get_current_user()
  if google_user is None:
    flask.flash(__('You denied the request to sign in.'))
    return flask.redirect(util.get_next_url())

  user_db = retrieve_user_from_google(google_user)
  return signin_user_db(user_db)
Beispiel #8
0
def signin_user_db(user_db):
    if not user_db:
        return flask.redirect(flask.url_for('signin'))
    flask_user_db = FlaskUser(user_db)
    if login.login_user(flask_user_db):
        flask.flash(__(
            'Hello %(name)s, welcome to %(brand)s!!!',
            name=user_db.name,
            brand=config.CONFIG_DB.brand_name,
        ),
                    category='success')
        response = flask.redirect(util.get_next_url())
        util.set_locale(user_db.locale, response)
        return response
    else:
        flask.flash(__('Sorry, but you could not sign in.'), category='danger')
        return flask.redirect(flask.url_for('signin'))
Beispiel #9
0
def twitter_authorized(resp):
    if resp is None:
        flask.flash(__('You denied the request to sign in.'))
        return flask.redirect(util.get_next_url())

    flask.session['oauth_token'] = (resp['oauth_token'],
                                    resp['oauth_token_secret'])
    user_db = retrieve_user_from_twitter(resp)
    return signin_user_db(user_db)
Beispiel #10
0
def twitter_oauth_authorized(resp):
  if resp is None:
    flask.flash(__('You denied the request to sign in.'))
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (
    resp['oauth_token'],
    resp['oauth_token_secret']
  )
  user_db = retrieve_user_from_twitter(resp)
  return signin_user_db(user_db)
Beispiel #11
0
def signin_twitter():
    flask.session.pop('oauth_token', None)
    try:
        return twitter.authorize(callback=flask.url_for(
            'twitter_authorized', next=util.get_next_url()), )
    except:
        flask.flash(
            __('Something went wrong with Twitter sign in. Please try again.'),
            category='danger',
        )
        return flask.redirect(flask.url_for('signin',
                                            next=util.get_next_url()))
Beispiel #12
0
def signin_twitter():
  flask.session.pop('oauth_token', None)
  try:
    return twitter.authorize(
        callback=flask.url_for('twitter_oauth_authorized',
        next=util.get_next_url()),
      )
  except:
    flask.flash(
        __('Something went wrong with Twitter sign in. Please try again.'),
        category='danger',
      )
    return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
Beispiel #13
0
def signout():
    login.logout_user()
    flask.flash(__('You have been signed out.'))
    return flask.redirect(flask.url_for('welcome'))
Beispiel #14
0
def signout():
  login.logout_user()
  flask.flash(__('You have been signed out.'))
  return flask.redirect(flask.url_for('welcome'))
Beispiel #15
0
from flask import Blueprint, flash, g, Markup, redirect, render_template, request, session, url_for
from flaskext.babel import gettext as _, lazy_gettext as __
from flask.ext.login import login_required, login_user, logout_user

from app import app, login_manager
from ..decorators import crumbs
from . import db, LoginForm, module, RegistrationForm, User
from . import oauth_twitter
import controller

@login_manager.unauthorized_handler
def unauthorized():
    abort(401)

@module.route('/')
@crumbs(odict((('home', __("Home")), ('.index', __("My profile")))))
def index():
    return 'USER MODULE'

@module.route('/me')
@login_required
def profile():
    return render_template('users/profile.html', user=g.user)

@app.before_request
def before_request():
    """
    Get user's profile from database before request is handled
    """
    g.user = None
    if 'user_id' in session:
Beispiel #16
0
    return dict(languages=app.config['LANGUAGES'])

@app.route('/login', methods=['POST'])
def login():
    return redirect(url_for('users.login'))

@app.route('/logout')
def logout():
    return redirect(url_for('users.login'))

@app.route('/register', methods=['GET', 'POST'])
def register():
    return redirect(url_for('users.register'))

@app.route('/about/')
@crumbs(odict((('home', __("Home")), ('about', __("About")))))
def about():
    app.logger.debug("Entered /about")
    return render_template('about/overview.html')

@app.route('/about/features/')
@crumbs(odict((('home', __("Home")), ('about', __("About")), ('features', __("Features")))))
def features():
    app.logger.debug("Entered /about/features")
    return render_template('about/features.html')

@app.route('/screenshots/')
@app.route('/screenshots/<version>')
@crumbs(odict((('home', __("Home")), ('about', __("About")), ('screenshots', __("Screenshots")))))
def screenshots(version=None):
    if version == None: