def getTagId(ro, ru, key): ob = Tags.objects(select=key, ro=ro) if ob: return ob.get().clean_data()['_id'] new_Tags = { "select": key, "ro": ro, "ru": ru, "en": "-", "is_active": True } comment = Tags(**new_Tags) comment.save() return comment.clean_data()['_id']
def registerTag(requestjson, created_by): """create a new user""" new_Tags = requestjson if len(created_by) > 30: user = Operator.verify_auth_token(created_by) created_by = user.get().clean_data()['email'] # TODO: get authenticated operator and assignee to new Tags # new_Tags["created_by"] = authenticated_oprator try: new_Tags['created_by'] = created_by #g.user.get().clean_data()['_id'] comment = Tags(**new_Tags) comment.save() return jsonify({"response": "success", 'user': comment.clean_data()}) except Exception as error: return jsonify({"error": str(error)}), 400