def get_status(): """ :return: """ building = status.current_status iso_release = bool(request.args.get('do_iso_release', False)) and user.is_authenticated() reset_queue = bool(request.args.get('reset_build_queue', False)) and user.is_authenticated() if iso_release: queue.enqueue_call(iso.iso_release_job) message = dict(msg='Ok') return json.dumps(message) elif reset_queue: if queue.count > 0: queue.empty() if repo_queue.count > 0: repo_queue.empty() items = len(status.queue) if items > 0: for item in range(items): popped = status.queue.rpop() logger.debug(popped) status.idle = True status.current_status = 'Idle.' message = dict(msg='Ok') return json.dumps(message) else: return Response(get_live_status_updates(), direct_passthrough=True, mimetype='text/event-stream')
def register(): """ This view allows a user to register for the site. This will create a new User in Stormpath, and then log the user into their new account immediately (no email verification required). """ if request.method == 'GET': if user.is_authenticated(): return redirect(url_for('index')) return render_template('register.html') try: _user = stormpath_manager.application.accounts.create({ 'username': request.form.get('username'), 'email': request.form.get('email'), 'password': request.form.get('password'), 'given_name': request.form.get('first_name'), 'surname': request.form.get('last_name') }) _user.__class__ = User app_user = AppUser(_user.get_id()) db.session.add(app_user) db.session.commit() except StormpathError, err: return render_template('register.html', error=err.message)
def index(): if user.is_authenticated(): return redirect(url_for('success')) client = Client(api_key_file_location=app.config['STORMPATH_API_KEY_FILE']) a = client.applications.search(app.config['STORMPATH_APPLICATION'])[0] html = '' # delete user if it already exists email = '*****@*****.**' for i in a.accounts: if i.email == email: html = html + 'deleting account ' + i.email + '<br>' i.delete() # create the account password = '******' username = '******' html = html + 'creating account ' + email + '<br>' account = a.accounts.create({ 'given_name': 'John', 'surname': 'Doe', 'username': username, 'email': email, 'password': password, }) html = html + ''' Login using these credentials:<br> <b>%s <br></b> <b>%s <br></b> <a href="/login">Login</a> ''' % (email, password) return html
def dev_pkg_check(page=None): build_status = 'completed' set_rev_error = False set_rev_error_msg = None review = True is_logged_in = user.is_authenticated() if page is None: page = 1 if request.method == 'POST': payload = json.loads(request.data) bnum = payload['bnum'] dev = payload['dev'] result = payload['result'] if all(i is not None for i in (bnum, dev, result)): set_review = set_pkg_review_result(bnum, dev, result) if set_review.get('error'): set_rev_error = set_review.get('msg') message = dict(msg=set_rev_error) return json.dumps(message) else: message = dict(msg='ok') return json.dumps(message) completed, all_pages, rev_pending = get_build_info(page, build_status, is_logged_in) pagination = utils.pagination.Pagination(page, 10, len(rev_pending)) return render_template("pkg_review.html", completed=completed, all_pages=all_pages, set_rev_error=set_rev_error, set_rev_error_msg=set_rev_error_msg, user=user, rev_pending=rev_pending, pagination=pagination)
def register(): """ This view allows a user to register for the site. This will create a new User in Stormpath, and then log the user into their new account immediately (no email verification required). """ if request.method == 'GET': if user.is_authenticated(): return redirect(url_for('index')) return render_template('register.html') is_author = True if request.form.get('is_author') is not None else False try: _user = stormpath_manager.application.accounts.create({ 'username': request.form.get('username'), 'email': request.form.get('email'), 'password': request.form.get('password'), 'given_name': request.form.get('first_name'), 'surname': request.form.get('last_name'), 'custom_data': { 'is_author': is_author } }) _user.__class__ = User except StormpathError, err: return render_template('register.html', error=err.message)
def cache_buster(): if db.exists('antbs:misc:cache_buster:flag'): db.delete('antbs:misc:cache_buster:flag') return True elif user.is_authenticated(): return True return False
def repo_packages(repo=None): if repo is None or repo not in ['antergos', 'antergos-staging']: abort(404) is_logged_in = user.is_authenticated() building = status.now_building packages, rev_pending = get_repo_info(repo, is_logged_in) return render_template("repo_pkgs.html", building=building, repo_packages=packages, rev_pending=rev_pending, user=user, name=repo)
def build_pkg_now(): """ :return: """ if request.method == 'POST': pkgname = request.form['pkgname'] dev = request.form['dev'] if not pkgname or pkgname is None or pkgname == '': abort(500) pexists = status.all_packages pexists = pexists.ismember(pkgname) if not pexists: try: package.Package(name=pkgname) if os.path.exists('/var/tmp/antergos-packages/' + pkgname) or 'antergos-iso' in pkgname: pexists = True except Exception: pass if pexists: is_logged_in = user.is_authenticated() p, a, rev_pending = get_build_info(1, 'completed', is_logged_in) # logger.info(rev_pending) pending = False for bnum in rev_pending.keys(): bld_obj = build_obj.get_build_object(bnum=bnum) if pkgname == bld_obj.pkgname: pending = True break if pending: flash('Unable to build %s because it is in "pending review" status.' % pkgname, category='error') else: if '-x86_64' in pkgname or '-i686' in pkgname: if not status.iso_building: status.iso_flag = True if 'minimal' in pkgname: status.iso_minimal = True else: status.iso_minimal = False else: logger.info('RATE LIMIT ON ANTERGOS ISO IN EFFECT') return redirect(redirect_url()) q = status.hook_queue q.rpush(pkgname) hook_queue.enqueue_call(builder.handle_hook, timeout=84600) tl_event( msg='<strong>%s</strong> added <strong>%s</strong> to the build queue.' % (dev, pkgname), tl_type='0') else: flash('Package not found. Has the PKGBUILD been pushed to github?', category='error') return redirect(redirect_url())
def showPublic(): # 3 options on this page # 1. Create a new event # 2. list my events # 3. Search for an event (that user has been invited to) #check user for authenticated and if so redirect to '/public/loggedin' if user.is_authenticated(): return redirect(url_for('showLoggedin')) else: return render_template('public.html')
def failed(page=None): build_status = 'failed' if page is None: page = 1 building = status.now_building is_logged_in = user.is_authenticated() failed, all_pages, rev_pending = get_build_info(page, build_status, is_logged_in) pagination = utils.pagination.Pagination(page, 10, all_pages) return render_template("failed.html", building=building, failed=failed, all_pages=all_pages, page=page, rev_pending=rev_pending, user=user, pagination=pagination)
def completed(page=None, name=None): build_status = 'completed' is_logged_in = user.is_authenticated() if page is None and name is None: page = 1 if name is not None and page is None: page = 1 building = status.now_building completed, all_pages, rev_pending = get_build_info(page, build_status, is_logged_in, name) pagination = utils.pagination.Pagination(page, 10, all_pages) return render_template("completed.html", building=building, completed=completed, all_pages=all_pages, rev_pending=rev_pending, user=user, pagination=pagination)
def login(): """ User login/auth/session management """ if request.method == 'GET': if user.is_authenticated(): return redirect(url_for('index')) return render_template('login.html') try: _user = User.from_login( request.form.get('email'), request.form.get('password'), ) except StormpathError, err: return render_template('login.html', error=err.message)
def readers(): if user.is_authenticated(): return render_template('readers.html') return render_template('readers.html')
def makers(): """ """ if user.is_authenticated(): return render_template('makers.html') return render_template('makers.html')
def inject_appuser(): if user.is_authenticated(): user_id = user.get_id() app_user = AppUser.query.get(stormpathUserHash(user_id)) return dict(app_user=app_user) return dict(app_user=None)
def index(): if user.is_authenticated(): return render_template('index.html', title='{0} {1}'.format(user.given_name, user.surname)) else: return render_template('landing.html', title='Home')