Ejemplo n.º 1
0
Archivo: views.py Proyecto: raffas/lino
 def delete(self, request, app_label=None, actor=None, pk=None):
     data = http.QueryDict(request.body)
     ar = action_request(
         app_label, actor, request, data, False,
         renderer=settings.SITE.ui.extjs_renderer)
     ar.set_selected_pks(pk)
     return settings.SITE.ui.run_action(ar)
Ejemplo n.º 2
0
Archivo: views.py Proyecto: cuchac/lino
 def put(self, request, app_label=None, actor=None, pk=None):
     data = http.QueryDict(request.body)  # raw_post_data before Django 1.4
     ar = action_request(app_label, actor, request, data, False)
     ar.set_selected_pks(pk)
     ar.renderer = settings.SITE.ui.extjs_renderer
     elem = ar.selected_rows[0]
     return form2obj_and_save(ar, data, elem, False, False)
Ejemplo n.º 3
0
Archivo: views.py Proyecto: cuchac/lino
 def post(self, request, app_label=None, actor=None, pk=None):
     ar = action_request(app_label, actor, request, request.POST, True)
     if pk == '-99998':
         elem = ar.create_instance()
         ar.selected_rows = [elem]
     else:
         ar.set_selected_pks(pk)
     ar.renderer = settings.SITE.ui.extjs_renderer
     return settings.SITE.ui.run_action(ar)
Ejemplo n.º 4
0
Archivo: views.py Proyecto: cuchac/lino
 def get(self, request, app_label=None, actor=None):
     ar = action_request(app_label, actor, request, request.GET, True)
     ar.renderer = settings.SITE.ui.plain_renderer
     context = dict(
         title=ar.get_title(),
         heading=ar.get_title(),
         #~ tbar = buttons,
         main=ar.as_bootstrap_html(),
     )
     context.update(ar=ar)
     return plain_response(settings.SITE.ui, request, 'table.html', context)
Ejemplo n.º 5
0
    def get(self, request, app_label=None, actor=None, pk=None):
        ui = settings.SITE.ui
        ar = action_request(app_label, actor, request, request.GET, False)
        ar.renderer = dd.plugins.bootstrap3.renderer

        context = dict(
            title=ar.get_action_title(),
            #~ menu = E.tostring(menu),
            #~ tbar = buttons,
            main=ar.as_bootstrap_html(pk),
        )
        #~ template = web.jinja_env.get_template('detail.html')
        context.update(ar=ar)

        return http_response(ui, request, 'bootstrap3/detail.html', context)
Ejemplo n.º 6
0
Archivo: views.py Proyecto: cuchac/lino
 def post(self, request, app_label=None, actor=None):
     ar = action_request(app_label, actor, request, request.POST, True)
     ar.renderer = settings.SITE.ui.extjs_renderer
     #~ print 20121116, ar.bound_action.action.action_name
     if ar.bound_action.action.action_name in [
             'duplicate', 'post', 'poststay', 'insert']:
         rh = ar.ah
         elem = ar.create_instance()
         if rh.actor.handle_uploaded_files is not None:
             rh.actor.handle_uploaded_files(elem, request)
             file_upload = True
         else:
             file_upload = False
         return form2obj_and_save(ar, request.POST, elem, True,
                                  False, file_upload)
     return settings.SITE.ui.run_action(ar)
Ejemplo n.º 7
0
Archivo: views.py Proyecto: raffas/lino
    def get(self, request, app_label=None, actor=None):
        ar = action_request(app_label, actor, request, request.GET, True)
        ar.renderer = settings.SITE.ui.extjs_renderer
        rh = ar.ah

        fmt = request.GET.get(
            ext_requests.URL_PARAM_FORMAT,
            ar.bound_action.action.default_format)

        if fmt == ext_requests.URL_FORMAT_JSON:
            rows = [rh.store.row2list(ar, row)
                    for row in ar.sliced_data_iterator]
            total_count = ar.get_total_count()
            for row in ar.create_phantom_rows():
                d = rh.store.row2list(ar, row)
                rows.append(d)
                total_count += 1
            kw = dict(count=total_count,
                      rows=rows,
                      success=True,
                      no_data_text=ar.no_data_text,
                      title=unicode(ar.get_title()))
            if ar.actor.parameters:
                kw.update(
                    param_values=ar.actor.params_layout.params_store.pv2dict(
                        ar.param_values))
            return json_response(kw)

        if fmt == ext_requests.URL_FORMAT_HTML:
            after_show = ar.get_status()

            sp = request.GET.get(
                ext_requests.URL_PARAM_SHOW_PARAMS_PANEL, None)
            if sp is not None:
                #~ after_show.update(show_params_panel=sp)
                after_show.update(
                    show_params_panel=ext_requests.parse_boolean(sp))

            if isinstance(ar.bound_action.action, actions.InsertRow):
                elem = ar.create_instance()
                #~ print 20120630
                #~ print elem.national_id
                rec = ar.elem2rec_insert(rh, elem)
                after_show.update(data_record=rec)

            kw = dict(on_ready=
                      ar.renderer.action_call(
                          ar.request,
                          ar.bound_action, after_show))
            #~ print '20110714 on_ready', params
            kw.update(title=ar.get_title())
            return http.HttpResponse(ar.renderer.html_page(request, **kw))

        if fmt == 'csv':
            #~ response = HttpResponse(mimetype='text/csv')
            charset = settings.SITE.csv_params.get('encoding', 'utf-8')
            response = http.HttpResponse(
                content_type='text/csv;charset="%s"' % charset)
            if False:
                response['Content-Disposition'] = \
                    'attachment; filename="%s.csv"' % ar.actor
            else:
                #~ response = HttpResponse(content_type='application/csv')
                response['Content-Disposition'] = \
                    'inline; filename="%s.csv"' % ar.actor

            #~ response['Content-Disposition'] = 'attachment; filename=%s.csv' % ar.get_base_filename()
            w = ucsv.UnicodeWriter(response, **settings.SITE.csv_params)
            w.writerow(ar.ah.store.column_names())
            if True:  # 20130418 : also column headers, not only internal names
                column_names = None
                fields, headers, cellwidths = ar.get_field_info(column_names)
                w.writerow(headers)

            for row in ar.data_iterator:
                w.writerow([unicode(v) for v in rh.store.row2list(ar, row)])
            return response

        if fmt == ext_requests.URL_FORMAT_PRINTER:
            if ar.get_total_count() > MAX_ROW_COUNT:
                raise Exception(_("List contains more than %d rows") %
                                MAX_ROW_COUNT)
            response = http.HttpResponse(
                content_type='text/html;charset="utf-8"')
            doc = xghtml.Document(force_unicode(ar.get_title()))
            doc.body.append(E.h1(doc.title))
            t = doc.add_table()
            #~ settings.SITE.ui.ar2html(ar,t,ar.data_iterator)
            ar.dump2html(t, ar.data_iterator)
            doc.write(response, encoding='utf-8')
            return response

        return settings.SITE.ui.run_action(ar)
Ejemplo n.º 8
0
Archivo: views.py Proyecto: raffas/lino
 def post(self, request, app_label=None, actor=None):
     ar = action_request(app_label, actor, request, request.POST, True)
     ar.renderer = settings.SITE.ui.extjs_renderer
     return settings.SITE.ui.run_action(ar)