コード例 #1
0
def new_application():
    user = require_user()
    errors = []
    title = 'New Application'
    if request.form.get('submit'):
        name = request.form.get('name')
        if not name:
            errors.append('Missing application name')
        version = request.form.get('version')
        if not version:
            errors.append('Missing version number')
        email = request.form.get('email')
        if not email:
            errors.append('Missing email address')
        if email and not is_valid_email(email):
            errors.append('Invalid email address')
        website = request.form.get('website')
        if website and not is_valid_url(website):
            errors.append('Invalid website URL')
        if not errors:
            insert_application(db.session.connection(), {
                'name': name,
                'version': version,
                'email': email,
                'website': website,
                'account_id': user.id,
            })
            db.session.commit()
            return redirect(url_for('.applications'))
    return render_template('new-application.html', title=title,
        form=request.form, errors=errors)
コード例 #2
0
 def _handle_request(self, req):
     self.require_user(req)
     errors = []
     title = 'New Applications'
     if req.form.get('submit'):
         name = req.form.get('name')
         if not name:
             errors.append('Missing application name')
         version = req.form.get('version')
         if not version:
             errors.append('Missing version number')
         email = req.form.get('email')
         if email and not is_valid_email(email):
             errors.append('Invalid email address')
         website = req.form.get('website')
         if website and not is_valid_url(website):
             errors.append('Invalid website URL')
         if not errors:
             insert_application(self.conn, {
                 'name': name,
                 'version': version,
                 'email': req.form.get('email'),
                 'website': req.form.get('website'),
                 'account_id': self.session['id'],
             })
             return redirect(self.config.base_url + 'applications')
     return self.render_template('new-application.html', title=title,
         form=req.form, errors=errors)
コード例 #3
0
ファイル: apps.py プロジェクト: lessc0de/acoustid-server
def new_application():
    user = require_user()
    errors = []
    title = 'New Application'
    if request.form.get('submit'):
        name = request.form.get('name')
        if not name:
            errors.append('Missing application name')
        version = request.form.get('version')
        if not version:
            errors.append('Missing version number')
        email = request.form.get('email')
        if email and not is_valid_email(email):
            errors.append('Invalid email address')
        website = request.form.get('website')
        if website and not is_valid_url(website):
            errors.append('Invalid website URL')
        if not errors:
            insert_application(db.session.connection(), {
                'name': name,
                'version': version,
                'email': email,
                'website': website,
                'account_id': user.id,
            })
            db.session.commit()
            return redirect(url_for('.applications'))
    return render_template('new-application.html', title=title,
        form=request.form, errors=errors)
コード例 #4
0
ファイル: internal.py プロジェクト: ncarkaci/acoustid-server
 def _handle_internal(self, params):
     if self.cluster.secret != params.secret:
         logger.warning('Invalid cluster secret')
         raise errors.NotAllowedError()
     application_id, application_api_key = insert_application(self.conn, {
         'account_id': params.account_id,
         'name': params.name,
         'version': params.version,
     })
     return {'id': application_id, 'api_key': application_api_key}
コード例 #5
0
ファイル: internal.py プロジェクト: acoustid/acoustid-server
 def _handle_internal(self, params):
     if self.cluster.secret != params.secret:
         logger.warning('Invalid cluster secret')
         raise errors.NotAllowedError()
     application_id, application_api_key = insert_application(self.conn, {
         'account_id': params.account_id,
         'name': params.name,
         'version': params.version,
     })
     return {'id': application_id, 'api_key': application_api_key}
コード例 #6
0
ファイル: website.py プロジェクト: mineo/acoustid-server
 def _handle_request(self, req):
     self.require_user(req)
     errors = []
     title = 'New Applications'
     if req.form.get('submit'):
         name = req.form.get('name')
         version = req.form.get('version')
         if name and version:
             insert_application(self.conn, {
                 'name': name,
                 'version': version,
                 'account_id': self.session['id'],
             })
             return redirect(self.config.base_url + 'applications')
         else:
             if not name:
                 errors.append('Missing application name')
             if not version:
                 errors.append('Missing version number')
     return self.render_template('new-application.html', title=title,
         form=req.form, errors=errors)
コード例 #7
0
 def _handle_request(self, req):
     self.require_user()
     errors = []
     title = 'New Applications'
     if req.form.get('submit'):
         name = req.form.get('name')
         version = req.form.get('version')
         if name and version:
             insert_application(self.conn, {
                 'name': name,
                 'version': version,
                 'account_id': self.session['id'],
             })
             return redirect(self.config.base_url + 'applications')
         else:
             if not name:
                 errors.append('Missing application name')
             if not version:
                 errors.append('Missing version number')
     return self.render_template('new-application.html', title=title,
         form=req.form, errors=errors)