def task_id_edit(_id=None): task_id_form = TaskIDForm() task_id_query = TaskId.objects.get_or_404(_id=_id) if task_id_form.validate_on_submit(): data = task_id_form.data data_count = Specie.objects(srr_id=data["srr_id"]).count() if data_count == 0: TaskId.objects(task_id=_id).update_one(set__srr_id=data["srr_id"]) TaskId.objects(task_id=_id).update_one(set__email=data["email"]) TaskId.objects(task_id=_id).update_one( set__task_time=datetime.now()) flash("edit done !", "ok") return redirect(url_for("admin.task_id_edit", _id=_id)) elif data_count == 1 and task_id_query.srr_id != data["srr_id"]: flash("this task is already exist !", "err") return redirect(url_for("admin.task_id_edit", _id=_id)) elif data_count == 1 and task_id_query.srr_id == data["srr_id"]: TaskId.objects(task_id=_id).update_one(set__email=data["email"]) TaskId.objects(task_id=_id).update_one( set__task_time=datetime.now()) flash("edit done !", "ok") return redirect(url_for("admin.task_id_edit", _id=_id)) return render_template("admin/task_id_edit.html", form=task_id_form, task_id=task_id_query)
def task_id(_id): task_query = TaskId.objects(task_id=_id).first() srr_id_query = task_query.srr_id srr_task_query = SrrTask.objects.get_or_404(_id=srr_id_query) each = {"_id": srr_task_query._id, "kegg_id": srr_task_query.kegg_id, "method": srr_task_query.method, "operon": srr_task_query.operon_path, "jbrowse": srr_task_query.browse_link} return render_template("home/task.html", each=each)
def validate_srr_id(self, field): data = field.data data_count = TaskId.objects(srr_id=data).count() if data_count > 0: raise ValidationError("the srr id is already exist !")
def task_id_del(_id=None): TaskId.objects(task_id=_id).delete() flash("delete it done !", "ok") return redirect(url_for("admin.task_id"))
def task_id(page=None): if page is None: page = 1 page_data = TaskId.objects().paginate(page=page, per_page=10) return render_template("admin/task_id.html", page_data=page_data)