Ejemplo n.º 1
0
 def post(self, source_type):
     if source_type == 'json':
         file_path = get_file_from_request(['zip'])
     elif source_type == 'pentabarf':
         file_path = get_file_from_request(['xml'])
     elif source_type == 'ical':
         file_path = get_file_from_request(['ical'])
     else:
         file_path = None
         abort(404)
     from helpers.tasks import import_event_task
     task = import_event_task.delay(file=file_path, source_type=source_type, creator_id=g.user.id)
     # store import job in db
     try:
         create_import_job(task.id)
     except Exception:
         pass
     # if testing
     if current_app.config.get('CELERY_ALWAYS_EAGER'):
         send_import_mail(task.id, task.get())
         TASK_RESULTS[task.id] = {
             'result': task.get(),
             'state': task.state
         }
     return jsonify(
         task_url=url_for('api.extras_celery_task', task_id=task.id)
     )
Ejemplo n.º 2
0
 def post(self, source_type):
     if source_type == 'json':
         file_path = get_file_from_request(['zip'])
     elif source_type == 'pentabarf':
         file_path = get_file_from_request(['xml'])
     elif source_type == 'ical':
         file_path = get_file_from_request(['ical', 'ics'])
     else:
         file_path = None
         abort(404)
     from helpers.tasks import import_event_task
     task = import_event_task.delay(file=file_path,
                                    source_type=source_type,
                                    creator_id=g.user.id)
     # store import job in db
     try:
         create_import_job(task.id)
     except Exception:
         pass
     # if testing
     if current_app.config.get('CELERY_ALWAYS_EAGER'):
         send_import_mail(task.id, task.get())
         TASK_RESULTS[task.id] = {'result': task.get(), 'state': task.state}
     return jsonify(
         task_url=url_for('api.extras_celery_task', task_id=task.id))
Ejemplo n.º 3
0
 def post(self):
     file = get_file_from_request(['zip'])
     from helpers.tasks import import_event_task
     task = import_event_task.delay(file)
     if current_app.config.get('CELERY_ALWAYS_EAGER'):
         TASK_RESULTS[task.id] = {
             'result': task.get(),
             'state': task.state
         }
     return jsonify(
         task_url=url_for('api.extras_celery_task', task_id=task.id)
     )
def import_event(source_type):
    if source_type == 'json':
        file_path = get_file_from_request(['zip'])
    else:
        file_path = None
        abort(404)
    from helpers.tasks import import_event_task
    task = import_event_task.delay(email=current_identity.email,
                                   file=file_path,
                                   source_type=source_type,
                                   creator_id=current_identity.id)
    # create import job
    create_import_job(task.id)

    # if testing
    if current_app.config.get('CELERY_ALWAYS_EAGER'):
        TASK_RESULTS[task.id] = {'result': task.get(), 'state': task.state}
    return jsonify(task_url=url_for('tasks.celery_task', task_id=task.id))
 def post(self):
     file_path = get_file_from_request(['zip'])
     from helpers.tasks import import_event_task
     task = import_event_task.delay(file_path)
     # store import job in db
     try:
         create_import_job(task.id)
     except Exception:
         pass
     # if testing
     if current_app.config.get('CELERY_ALWAYS_EAGER'):
         send_import_mail(task.id, task.get())
         TASK_RESULTS[task.id] = {
             'result': task.get(),
             'state': task.state
         }
     return jsonify(
         task_url=url_for('api.extras_celery_task', task_id=task.id)
     )
Ejemplo n.º 6
0
 def post(self):
     file = get_file_from_request(['zip'])
     from helpers.tasks import import_event_task
     task = import_event_task.delay(file)
     # store import job in db
     try:
         create_import_job(task.id)
     except Exception:
         pass
     # if testing
     if current_app.config.get('CELERY_ALWAYS_EAGER'):
         send_import_mail(task.id, task.get())
         TASK_RESULTS[task.id] = {
             'result': task.get(),
             'state': task.state
         }
     return jsonify(
         task_url=url_for('api.extras_celery_task', task_id=task.id)
     )
Ejemplo n.º 7
0
def import_event(source_type):
    if source_type == 'json':
        file_path = get_file_from_request(['zip'])
    else:
        file_path = None
        abort(404)
    from helpers.tasks import import_event_task
    task = import_event_task.delay(email=current_identity.email, file=file_path,
                                   source_type=source_type, creator_id=current_identity.id)
    # create import job
    create_import_job(task.id)

    # if testing
    if current_app.config.get('CELERY_ALWAYS_EAGER'):
        TASK_RESULTS[task.id] = {
            'result': task.get(),
            'state': task.state
        }
    return jsonify(
        task_url=url_for('tasks.celery_task', task_id=task.id)
    )