Esempio n. 1
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user).survey
     
     audit = {}
     audit_log(
         Actions.FORM_PUBLISHED, request.user, content_user,
         _("Published form '%(id_string)s'.") %
         {
             'id_string': survey.id_string,
         }, audit, request)
     enketo_webform_url = reverse(
         enter_data,
         kwargs={'username': username, 'id_string': survey.id_string}
     )
     return {
         'type': 'alert-success',
         'preview_url': reverse(enketo_preview, kwargs={
             'username': username,
             'id_string': survey.id_string
         }),
         'text': _(u'Successfully published %(form_id)s.'
                   u' <a href="%(form_url)s">Enter Web Form</a>'
                   u' or <a href="#preview-modal" data-toggle="modal">'
                   u'Preview Web Form</a>')
         % {'form_id': survey.id_string,
             'form_url': enketo_webform_url},
         'form_o': survey
     }
Esempio n. 2
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user).survey
     audit = {}
     audit_log(
         Actions.FORM_PUBLISHED,
         request.user,
         content_user,
         _("Published form '%(id_string)s'.") % {"id_string": survey.id_string},
         audit,
         request,
     )
     enketo_webform_url = reverse(enter_data, kwargs={"username": username, "id_string": survey.id_string})
     return {
         "type": "alert-success",
         "preview_url": reverse(enketo_preview, kwargs={"username": username, "id_string": survey.id_string}),
         "text": _(
             u"Successfully published %(form_id)s."
             u' <a href="%(form_url)s">Enter Web Form</a>'
             u' or <a href="#preview-modal" data-toggle="modal">'
             u"Preview Web Form</a>"
         )
         % {"form_id": survey.id_string, "form_url": enketo_webform_url},
         "form_o": survey,
     }
Esempio n. 3
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user, id_string).survey
     enketo_webform_url = reverse(
         enter_data,
         kwargs={'username': username, 'id_string': survey.id_string}
     )
     audit = {
         'xform': xform.id_string
     }
     audit_log(
         Actions.FORM_XLS_UPDATED, request.user, owner,
         _("XLS for '%(id_string)s' updated.") %
         {
             'id_string': xform.id_string,
         }, audit, request)
     return {
         'type': 'alert-success',
         'text': _(u'Successfully published %(form_id)s.'
                   u' <a href="%(form_url)s">Enter Web Form</a>'
                   u' or <a href="#preview-modal" data-toggle="modal">'
                   u'Preview Web Form</a>')
                 % {'form_id': survey.id_string,
                    'form_url': enketo_webform_url}
     }
Esempio n. 4
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user).survey
     return {
         'type': 'alert-success',
         'text': 'Successfully published %s.' % survey.id_string,
         }
Esempio n. 5
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user).survey
     return {
         'type': 'alert-success',
         'text': _(u'Successfully published %s.') % survey.id_string
     }
Esempio n. 6
0
def profile(request, username):
    context = RequestContext(request)
    content_user = None
    context.num_surveys = Instance.objects.count()
    context.form = QuickConverter()

    # xlsform submission...
    if request.method == 'POST' and request.user.is_authenticated():
        def set_form():
            form = QuickConverter(request.POST, request.FILES)
            survey = form.publish(request.user).survey
            return {
                'type': 'alert-success',
                'text': 'Successfully published %s.' % survey.id_string,
                }
        context.message = publish_form(set_form)

    # profile view...
    content_user = get_object_or_404(User, username=username)
    # for the same user -> dashboard
    if content_user == request.user:
        context.show_dashboard = True
        context.user_surveys = content_user.surveys.count()
        context.all_forms = content_user.xforms.count()
        context.form = QuickConverterFile()
        context.form_url = QuickConverterURL()
        context.odk_url = request.build_absolute_uri("/%s" % request.user.username)
    # for any other user -> profile
    profile, created = UserProfile.objects.get_or_create(user=content_user)
    set_profile_data(context, content_user)
    return render_to_response("profile.html", context_instance=context)
Esempio n. 7
0
def dashboard(request):
    context = RequestContext(request)
    context.form = QuickConverter()
    content_user = request.user
    set_profile_data(context, content_user)
    context.odk_url = request.build_absolute_uri("/%s" % request.user.username)
    return render_to_response("dashboard.html", context_instance=context)
Esempio n. 8
0
def profile(request, username):
    context = RequestContext(request)
    content_user = None
    context.num_surveys = Instance.objects.count()
    context.form = QuickConverter()

    # xlsform submission...
    if request.method == 'POST' and request.user.is_authenticated():
        try:
            form = QuickConverter(request.POST, request.FILES)
            survey = form.publish(request.user).survey
            context.message = {
                'type': 'success',
                'text': 'Successfully published %s.' % survey.id_string,
                }
        except (PyXFormError, XLSFormError) as e:
            context.message = {
                'type': 'error',
                'text': unicode(e),
                }
        except IntegrityError as e:
            context.message = {
                'type': 'error',
                'text': 'Form with this id already exists.',
                }

    # profile view...
    content_user = get_object_or_404(User, username=username)
    # for the same user -> dashboard
    if content_user == request.user:
        context.show_dashboard = True
        context.user_surveys = content_user.surveys.count()
        context.all_forms = content_user.xforms.count()
        context.form = QuickConverterFile()
        context.form_url = QuickConverterURL()
        context.odk_url = request.build_absolute_uri("/%s" % request.user.username)
    # for any other user -> profile
    profile, created = UserProfile.objects.get_or_create(user=content_user)
    set_profile_data(context, content_user)
    return render_to_response("profile.html", context_instance=context)
Esempio n. 9
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user, id_string).survey
     enketo_webform_url = reverse(enter_data, kwargs={"username": username, "id_string": survey.id_string})
     audit = {"xform": xform.id_string}
     audit_log(
         Actions.FORM_XLS_UPDATED,
         request.user,
         owner,
         _("XLS for '%(id_string)s' updated.") % {"id_string": xform.id_string},
         audit,
         request,
     )
     return {
         "type": "alert-success",
         "text": _(
             u"Successfully published %(form_id)s."
             u' <a href="%(form_url)s">Enter Web Form</a>'
             u' or <a href="#preview-modal" data-toggle="modal">'
             u"Preview Web Form</a>"
         )
         % {"form_id": survey.id_string, "form_url": enketo_webform_url},
     }
Esempio n. 10
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     return form.publish(project.organization)
Esempio n. 11
0
 def set_form():
     form = QuickConverter(request.POST, request.FILES)
     survey = form.publish(request.user).survey
     return {"type": "alert-success", "text": "Successfully published %s." % survey.id_string}