2014-10-11 03:54:24 +00:00
|
|
|
import logging
|
2016-10-20 22:19:59 +00:00
|
|
|
import uuid
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
2022-07-12 20:53:28 +00:00
|
|
|
from django.shortcuts import render
|
2015-12-21 23:15:51 +00:00
|
|
|
from django.template import RequestContext
|
2016-10-20 22:19:59 +00:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2022-07-12 20:53:28 +00:00
|
|
|
from django_nine import versions
|
2014-10-11 03:54:24 +00:00
|
|
|
|
2015-12-21 23:15:51 +00:00
|
|
|
from fobi.base import get_theme
|
2016-10-20 22:19:59 +00:00
|
|
|
from fobi.helpers import handle_uploaded_file
|
|
|
|
|
from fobi.models import FormEntry
|
|
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
logger = logging.getLogger("fobi")
|
2014-10-11 03:54:24 +00:00
|
|
|
|
2016-10-20 22:19:59 +00:00
|
|
|
__all__ = (
|
2022-07-12 20:53:28 +00:00
|
|
|
"endpoint",
|
|
|
|
|
"forms_list",
|
2016-10-20 22:19:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2014-10-11 03:54:24 +00:00
|
|
|
@csrf_exempt
|
|
|
|
|
def endpoint(request):
|
2016-10-20 22:19:59 +00:00
|
|
|
"""Endpoint.
|
2014-10-11 03:54:24 +00:00
|
|
|
|
|
|
|
|
:param django.http.HttpRequest request:
|
|
|
|
|
:return django.http.HttpResponse:
|
|
|
|
|
"""
|
|
|
|
|
logger.debug("POST: {0}\nFILES: {1}".format(request.POST, request.FILES))
|
|
|
|
|
|
|
|
|
|
for field_name, imf in request.FILES.items():
|
2022-07-12 20:53:28 +00:00
|
|
|
handle_uploaded_file("foo", "{0}".format(uuid.uuid4()))
|
2014-10-11 03:54:24 +00:00
|
|
|
|
2015-12-21 23:15:51 +00:00
|
|
|
return HttpResponse(
|
|
|
|
|
"POST: {0}\nFILES: {1}".format(request.POST, request.FILES)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2022-07-12 20:53:28 +00:00
|
|
|
def forms_list(request, template_name="foo/forms_list.html"):
|
2016-10-20 22:19:59 +00:00
|
|
|
"""Fobi forms list.
|
|
|
|
|
|
|
|
|
|
:param django.http.HttpRequest request:
|
|
|
|
|
:param string template_name:
|
|
|
|
|
:return django.http.HttpResponse:
|
2015-12-21 23:15:51 +00:00
|
|
|
"""
|
2022-07-12 20:53:28 +00:00
|
|
|
form_entries = FormEntry._default_manager.filter(
|
|
|
|
|
is_public=True
|
|
|
|
|
).select_related("user")
|
2015-12-21 23:15:51 +00:00
|
|
|
theme = get_theme(request=request, as_instance=True)
|
|
|
|
|
context = {
|
2022-07-12 20:53:28 +00:00
|
|
|
"form_entries": form_entries,
|
|
|
|
|
"theme": theme,
|
|
|
|
|
"show_custom_actions": False,
|
|
|
|
|
"show_edit_link": False,
|
|
|
|
|
"show_delete_link": False,
|
|
|
|
|
"show_export_link": False,
|
2015-12-21 23:15:51 +00:00
|
|
|
}
|
2016-10-20 22:19:59 +00:00
|
|
|
|
2020-01-11 01:11:28 +00:00
|
|
|
return render(request, template_name, context)
|