Beispiel #1
0
def upload():
    if not settings.TILKEE_ENABLED:
        raise BadRequest

    company = Office.query.filter_by(siret=request.args.get('siret')).first()
    if not company:
        return 'Cette entreprise n\'existe pas', 400

    error_template = None
    if not current_user.is_authenticated:
        error_template = "tilkee/login.html"
    elif not current_user.email:
        error_template = "tilkee/missing_email.html"
    if error_template:
        next_url = request.referrer + '#company-{}'.format(
            company.siret) if request.referrer else ''
        return render_template(error_template,
                               login_url=login_url(next_url=next_url))

    if request.method == 'GET':
        return render_template("tilkee/upload.html",
                               company=company,
                               file_extensions=utils.ALLOWED_FILE_EXTENSIONS)

    return upload_files(company, request.files.getlist('files'))
    def test_login_url_with_request(self):
        with app.test_request_context(path='/pioupiou', base_url='http://laser.com'):
            login_url = auth_utils.login_url()

        parsed = urllib.parse.urlsplit(login_url)
        querystring = urllib.parse.parse_qs(parsed.query)
        self.assertEqual(['http://laser.com/pioupiou'], querystring['next'])
Beispiel #3
0
    def test_login_url_with_next(self):
        next_url = 'http://infinityandbeyond.com/subpath?arg=value'
        with self.app_context:
            login_url = auth_utils.login_url(next_url=next_url)

        parsed = urllib.parse.urlsplit(login_url)
        querystring = urllib.parse.parse_qs(parsed.query)
        self.assertEqual([next_url], querystring['next'])
Beispiel #4
0
    def test_login_url(self):
        with self.app_context:
            login_url = auth_utils.login_url()

        parsed = urllib.parse.urlsplit(login_url)
        querystring = urllib.parse.parse_qs(parsed.query)
        self.assertIsNotNone(login_url)
        self.assertEqual(['1'], querystring['keep'])
        self.assertNotIn('next', querystring)