Exemple #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'])
Exemple #2
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))
Exemple #3
0
def export_users_posts():
    if current_user.get_tasks_in_progress():
        flash(_('A task is in progress!', 'info'))
    current_user.launch_task('export_posts', 'exporting Your posts')
    db.session.commit()
    flash(_('Task has been launched!', 'success'))
    return redirect(url_for('main.home', 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))
Exemple #5
0
def export_posts():
    if current_user.get_tasks(name='export_posts', complete=False):
        flash(_('Export already in progress.'))
    else:
        current_user.launch_task('export_posts', _('Export in progress.'))
        db.session.commit()
    return redirect(url_for('main.user', username=current_user.username))
def graph_figure(filenames):
    shutil.rmtree(current_app.config['DOWNLOAD_FOLDER'])
    os.makedirs(current_app.config['DOWNLOAD_FOLDER'], exist_ok=True)
    current_user.launch_task('graph_figures', _('Graphing figures...'))
    db.session.commit()
    time.sleep(5)
    return redirect(url_for('main.job_processing'))
Exemple #7
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))
Exemple #8
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))
def process_files_2():
    shutil.rmtree(current_app.config['DOWNLOAD_FOLDER'])
    os.makedirs(current_app.config['DOWNLOAD_FOLDER'], exist_ok=True)
    current_user.launch_task('process_files', _('Processing files...'), "two")
    db.session.commit()
    time.sleep(5)
    return redirect(url_for('main.processing'))
Exemple #10
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))
Exemple #11
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))
Exemple #12
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))
Exemple #13
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))
Exemple #14
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))
Exemple #15
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))
Exemple #16
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']))
Exemple #17
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'))
Exemple #18
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))
Exemple #19
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))
Exemple #20
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))
Exemple #21
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))
Exemple #22
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))
Exemple #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'})
Exemple #24
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))
Exemple #25
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))
Exemple #26
0
def water_plants():
    if _get_watering_in_queue():
        flash('Plants are being watered by ' +
              _get_watering_in_queue()[0].user.username + ', Progress ' +
              str(_get_watering_in_queue()[0].get_progress()) + '%')
    else:
        description = ' Watering plants...'
        current_user.launch_task('water_plants', description, 20)
        db.session.commit()
        g.last_watered = datetime.utcnow()
    return redirect(url_for('main.plants'))
Exemple #27
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'})
Exemple #28
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
Exemple #29
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))
Exemple #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))
def process_files_1():
    # if current_user.get_task_in_progress('process_files'):
    #     flash(_('A process task is currently in progress'))
    # else:
    shutil.rmtree(current_app.config['DOWNLOAD_FOLDER'])
    os.makedirs(current_app.config['DOWNLOAD_FOLDER'], exist_ok=True)
    current_user.launch_task('process_files', _('Processing files...'), "one")
    db.session.commit()
    # file_count = len(files)
    time.sleep(5)
    # return redirect(url_for('main.loading'))
    return redirect(url_for('main.processing'))