Beispiel #1
0
def reports():
    """
    
    This renders the reports page.
    It is only available to admin users.
    """

    user_check()
    form = ReportForm()
    if form.validate_on_submit():
        if current_user.get_task_in_progress('export_report'):
            print(current_user.get_task_in_progress('export_report'))
            flash(_('An export task is currently in progress'))
        if True:
            current_user.launch_task('export_report', 'Exporting reports...',
                                     form.users.data, form.products.data,
                                     form.to.data, form.frm.data)
            db.session.commit()
        return redirect(url_for('admin.reports'))
    return render_template('admin/reports.html',
                           title='Admin',
                           form=form,
                           items=session['items'],
                           total_products=session['total_products'],
                           total=session['total'])
Beispiel #2
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('帖子正在导出'))
    else:
        current_user.launch_task('export_posts', _('正在导出帖子…'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('Uma tarefa de exportação já esta sendo executada.'))
    else:
        current_user.launch_task('export_posts', _('Exportando postagens...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #4
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('An export task is currently in progress'))
    else:
        current_user.launch_task('export_posts', _('Exporting posts...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #5
0
def polling_pubsub():
    current_task = current_user.get_task_in_progress('polling_subscription')
    if request.method == 'GET':
        # Start polling
        if current_task:
            # flash('A polling task is currently in progress')
            current_app.logger.info('A polling task is currently in progress')
            resp_o = {'status': 'polling', 'task_id': current_task.id}
            status = 200
        else:
            task = current_user.launch_task(
                'polling_subscription',
                'Listening for pub/sub notifications',
                timeout=3600)
            db.session.commit()
            resp_o = {'status': 'success', 'task_id': task.id}
            status = 202
    else:
        # Stop polling
        if current_task:
            # flash('Terminating task polling for builds')
            current_app.logger.info('Terminating task polling for builds')
            current_task.complete = True
            db.session.commit()
            resp_o = {'status': 'terminated', 'task_id': current_task.id}
            status = 202
        else:
            resp_o = {'status': 'error', 'task_id': 0}
            status = 200
    return jsonify(resp_o), status
Beispiel #6
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('An export task is currently in progress'))
    else:
        current_user.launch_task('export_posts', _('Exporting posts...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #7
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('Экспорт сейчас в процессе. Дождитесь завершения текущего экспорта и попробуйте снова.'))
    else:
        current_user.launch_task('export_posts', _('Выгружаем посты...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #8
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash("Exporting your posts ....")
    else:
        current_user.launch_task('export_posts', "Exporting Posts...")
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #9
0
def example_task():
    if current_user.get_task_in_progress('example'):
        flash(_('An export task is currently in progress'))
    else:
        current_user.launch_task('example', _('Runing example task...'), 25)
        db.session.commit()
    return redirect(url_for('user.members'))
Beispiel #10
0
 def dispatch_request(self):
     if current_user.get_task_in_progress('export_posts'):
         flash(_('导出任务正在执行中'))
     else:
         current_user.launch_task('export_posts', _('导出帖子...'))
         db.session.commit()
     return redirect(url_for('main.user_info', username=current_user.username))
Beispiel #11
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash('一项导出任务正在执行..')
    else:
        current_user.launch_task('export_posts', 'Exporting posts...')
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #12
0
def export_posts():
    if current_user.get_task_in_progress("export_posts"):
        flash(_("An export task is currently in progress"))
    else:
        current_user.launch_task("export_posts", _("Exporting posts..."))
        db.session.commit()
    return redirect(url_for("main.user", username=current_user.username))
Beispiel #13
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('Экспорт уже выполняется'))
    else:
        current_user.launch_task('export_posts', _('Экспорт...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #14
0
def update_all_urls():
    if ga_blueprint.session.authorized:
        if current_user.get_task_in_progress('update_urls'):
            flash('Stats update is currently in progress', 'danger')
        else:
            try:
                ga_blueprint.session.get('https://www.googleapis.com/analytics/v3/management/accountSummaries')

            except (InvalidClientIdError, InvalidGrantError):

                flash('Your one hour Google session without refresh token has expired. Please submit the request again',
                      'danger')
                to_del = OAuth.query.filter_by(user_id=current_user.id,
                                               provider='ga-oauth').first()
                db.session.delete(to_del)
                db.session.commit()

                return redirect(url_for('ga-oauth.login'))

            # flash(ga_blueprint.session.token)
            current_user.launch_task('update_urls', 'Updating stats...',
                                     user_id=current_user.id,
                                     access_token=ga_blueprint.session.token['access_token'],
                                     project_id=session['project'])

            db.session.commit()

    else:
        flash("Cannot retrieve Google Analytics data. Please connect it!", 'danger')

    return redirect(url_for('core.dashboard', project_id=session['project']))
Beispiel #15
0
def export_posts():
    if current_user.get_task_in_progress('export_posts') is not None:
        flash(_('已经有导出任务在运行了'))
    else:
        current_user.add_task('export_posts', _('正在导出博客...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #16
0
def stop_export_posts():
    if current_user.get_task_in_progress('export_posts'):
        current_user.remove_tasks('export_posts')
        db.session.commit()
        flash(_('An export task is currently being stopped'))
    else:
        flash(_('No export task found.'))
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #17
0
def download_all(collection_name, filters):
    if current_user.get_task_in_progress(
            'download_one') or current_user.get_task_in_progress(
                'download_all'):
        flash('A download task is currently in progress')
    else:
        task = current_user.launch_task(name='download_all',
                                        description='Downloading runs...')
        db.session.commit()
        path = set_target_path(task)
        wait_for_download(path)
        return send_file(path, mimetype='application/zip', as_attachment=True)
    return redirect(
        url_for('main.data',
                filters=filters,
                collection_name=collection_name,
                page_num=1))
Beispiel #18
0
def lunch():
    if current_user.get_task_in_progress('lunch'):
        flash('An lunch task is currently in progress', category='warning')
    else:
        current_user.launch_task('lunch',
                                 'Searching for your Lunch buddies...', 100)
        db.session.commit()
    return redirect(url_for('user', username=current_user.username))
Beispiel #19
0
def export_posts():
    log_page_access(request, current_user)
    if current_user.get_task_in_progress('export_posts'):
        flash(_('An export task is currently in progress'))
    else:
        current_user.launch_task('export_posts', _('Exporting posts...'))
        db.session.commit()
    return redirect(url_for('main.user', guid=current_user.guid))
Beispiel #20
0
def request_impute():
    if current_user.get_task_in_progress('run_impute'):
        return 'An impute request is currently running'
    else:
        raw_data = json.loads(request.data)
        task = current_user.launch_task('run_impute', 'Impute', raw_data)
        db.session.commit()
        return task.id
Beispiel #21
0
def export_posts():
    if current_user.get_task_in_progress(name='export_posts'):
        flash(_('An export task is currently in progress'))
    else:
        current_user.launch_task(name='export_posts',
                                 description='Exporting posts...')
        flash(_('your task have been handle, please check your email late.'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #22
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash(_('An export task is currently in progress'))
    else:
        # export_posts is the function that will be passed to the rq worker
        # the 'Exporting posts...' is a friendly text description for the user
        current_user.launch_task('export_posts', _('Exporting posts...'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
Beispiel #23
0
def services_run():
    print("im here")
    if current_user.get_task_in_progress('upload_files_task'):
        flash('An export task is currently in progress')
    else:
        project = Project.query.get(request.form['project_id'])
        current_user.launch_task('upload_files_task', 'Uploading files...',
                                 request.form['form'], project, current_app)
        db.session.commit()
    return jsonify({'okay': 'okay'})
Beispiel #24
0
def picking_main():
    
    if current_user.get_task_in_progress('picking_main'):
        flash('A particle picking operation is already underway!')
    
    else:
        current_user.launch_task('picking_main', 'Particle Picking Activated...')
        db.session.commit()
    
    return redirect(url_for('main.pygempick', username=current_user.username))
Beispiel #25
0
def export_posts():
    if current_user.email == '':
        flash('You need to add a email before exporting your tweets', 'info')
        return redirect(url_for('users.user_profile', user_id=current_user.id))
    if current_user.get_task_in_progress('export_posts'):
        flash('An export task is currently in progress. Please wait', 'info')
    else:
        current_user.launch_task('export_posts', 'Exporting tweets')
        db.session.commit()
    return redirect(url_for('users.user_profile', user_id=current_user.id))
Beispiel #26
0
def consume_time(amount):
    log_page_access(request, current_user)
    if current_user.get_task_in_progress('consume_time'):
        flash(_('A time consuming task is currently in progress'))
    else:
        current_user.launch_task('consume_time',
                                 _('Consuming %(amount)s s of time...',
                                   amount=amount),
                                 amount=int(amount))
        db.session.commit()
    return redirect(url_for('main.user', guid=current_user.guid))
Beispiel #27
0
def export_posts():
    if current_app.redis is None:
        flash(_("Redis is not available"))
        return redirect(url_for('main.user', username=current_user.username))

    if current_user.get_task_in_progress('export_posts'):
        flash(_("Export is currently in progress"))
    else:
        current_user.launch_task('export_posts', _('Exporting posts...'))

    return redirect(url_for('main.user', username=current_user.username))
Beispiel #28
0
def services_run():
    if current_user.get_task_in_progress('run_services_task_bar'):
        flash('An export task is currently in progress')
    else:
        current_user.launch_task('run_services_task_bar',
                                 'Running services...', current_user.id,
                                 request.form['wells'],
                                 request.form['services'],
                                 request.form['run_id'])
        db.session.commit()
    return jsonify({'okay': 'okay'})
Beispiel #29
0
def export_posts():
    if current_user.get_task_in_progress('export_posts'):
        flash('An export task is currently in progress')
    else:
        current_user.launch_task('export_posts', 'Exporting posts...')
        db.session.commit() # after having already added task to session
    return redirect(url_for('main.user', username=current_user.username))

# set password criteria via validators
# functionality for deleting posts
# 'New Posts' divider based on current_user.last_seen
Beispiel #30
0
def pubmed_results(query):
    
    if current_user.get_task_in_progress('article_search'):
        flash('A pubmed search is already under way!')
    
    else:
        current_user.launch_task('article_search', 'Pubmed Searcher Activated...')
    
    time.sleep(4)
    
    return redirect(url_for('main.pubmed_search', username=current_user.username))
Beispiel #31
0
def progress_import():
    try:
        request.get_json()
    except:
        return '', 400

    task = current_user.get_task_in_progress('import_list')
    if task:
        progress = {'progress': round(task.get_progress(), 2)}
    else:
        progress = {'progress': 100}

    return jsonify(progress=progress), 200