Exemplo n.º 1
0
def view_import(request):
    base_url = _base_url
    app_url = _app_url
    tabs = views.get_tab_html(_base_url)
    message = None
    if not request.user.is_authenticated():
        export_data = ""
        return render_to_response('import.html', locals(),
                          context_instance=RequestContext(request))
    user = models.get_user(request)
    if request.method == "POST":
        method = request.POST["method"]
        if method == "login":
            message = login(request)
            user = models.get_user(request)
        elif method == "logout":
            message = logout(request)
            user = models.get_user("anonymous")
        elif method == "import":
            mode = request.POST["mode"]
            import_data = request.POST["import_data"]
            models.import_data(import_data, mode, user)
            return HttpResponse("Import successfully")
        elif method == "export":
            mode = request.POST["mode"]
            export_data = models.export_data(mode, user)
            return HttpResponse(export_data)
    export_data = models.export_data("json", user)
    return render_to_response('import.html', locals(),
                              context_instance=RequestContext(request))
Exemplo n.º 2
0
def ajax_task_table(request, tab_name="", view_name=""):
    date_query = request.POST.get("query", "")
    user = models.get_user(request)
    tasks = views.get_tasks(tab_name, view_name, user, date_query)
    json_obj = views.task_table(tasks, request)
    return HttpResponse(json.dumps(json_obj))
Exemplo n.º 3
0
def add_task(request):
    task_string = request.POST["new_task"]
    user = models.get_user(request)
    taskcard = models.TaskCard.create(user, task_string)
    return "create ok: (%s) %s" % (taskcard.data_type_as_string(), taskcard.title)