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 tasks(page=1): q = request.args.get('q', '', type=str) page = int(page) if q: tasks, _ = Task.search(f'(user_id:{current_user.id}) AND {q}*', page=page, per_page=current_app.config['TASK_PER_PAGE']) else: tasks = current_user.get_tasks(page) return render_template("fragments/tasks.html", tasks=tasks)
def return_data(): events = [] # get all tasks of user tasks = current_user.get_tasks() for task in tasks: code = task.module.code.upper() title = task.title # create event event_title = f"{code}: {title}" event_start = task.start_timestamp event_end = task.end_timestamp event = {"title": event_title, "start": event_start, "end": event_end} # add event to list events.append(event) # return events list as json response return jsonify(events)
def index(): form = g.task_upload_form schedule_form = g.schedule_form if request.method == 'POST': if schedule_form.periodicity.data != None: task_id = schedule_form.scheduled_task_id.data bots = schedule_form.bots_comma_list.data schedule_form.init_date.data = request.form['date1'] schedule_form.end_date.data = request.form['date2'] schedule_form.init_time.data = request.form['time1'] schedule_form.end_time.data = request.form['time2'] as_scheduled_str = schedule_form.as_scheduled_str() # Pendiente a modificar para su ejecución. // db_helper.py -> línea 181 #message = schedule_job_on_bots(task_id=task_id, bots=bots, as_scheduled_str=as_scheduled_str) if schedule_form.periodicity.data == 'MINUTE': minutes = schedule_form.at_minutes.data as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) elif schedule_form.periodicity.data == 'HOUR': schedule_form.at_minutes.data = schedule_form.at_hour.data as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) elif schedule_form.periodicity.data == 'DAY': days = schedule_form.on_day.data as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) elif schedule_form.periodicity.data == 'WEEK': weeks = schedule_form.at_week.data day_week = request.form['day'] if day_week == 'Dom': schedule_form.the_day.data = 'sunday' elif day_week == 'Lun': schedule_form.the_day.data = 'monday' elif day_week == 'Mar': schedule_form.the_day.data = 'tuesday' elif day_week == 'Mier': schedule_form.the_day.data = 'wednesday' elif day_week == 'Jue': schedule_form.the_day.data = 'thursday' elif day_week == 'Vie': schedule_form.the_day.data = 'friday' elif day_week == 'Sab': schedule_form.the_day.data = 'saturday' as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) elif schedule_form.periodicity.data == 'MONTHLY': months = schedule_form.on_month_day.data as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) elif schedule_form.periodicity.data == 'YEARLY': years = schedule_form.on_month_day2.data month_year = request.form['year'] if month_year == 'Ene': schedule_form.on_month.data = 'January' elif month_year == 'Feb': schedule_form.on_month.data = 'February' elif month_year == 'Mar': schedule_form.on_month.data = 'March' elif month_year == 'Abr': schedule_form.on_month.data = 'April' elif month_year == 'May': schedule_form.on_month.data = 'May' elif month_year == 'Jun': schedule_form.on_month.data = 'June' elif month_year == 'Jul': schedule_form.on_month.data = 'July' elif month_year == 'Ago': schedule_form.on_month.data = 'August' elif month_year == 'Sep': schedule_form.on_month.data = 'September' elif month_year == 'Oct': schedule_form.on_month.data = 'October' elif month_year == 'Nov': schedule_form.on_month.data = 'November' elif month_year == 'Dic': schedule_form.on_month.data = 'December' as_scheduled_str = schedule_form.as_scheduled_str() print(as_scheduled_str) else: schedule_form.init_date.data = request.form['uniq_init_date'] schedule_form.init_time.data = request.form['uniq_init_time'] init = schedule_form.init_date.data time = schedule_form.init_time.data print(init) print(time) return redirect(url_for('auth.login')) tasks = current_user.get_tasks() bots = get_bots(1) current_date = datetime.now() current_time = str(current_date.time()) dates = { 'tasks': tasks, 'bots': bots, 'current_date': current_date, 'current_time': current_time, } return render_template('index.html', **dates)
def get_tasklist(): ret = sorted([task for task in current_user.get_tasks()], key=lambda v: v.finish_time) ret = [task.get_info_map() for task in ret] return Validity(True, {'task list': ret}).get_resp()