def salvar(request, pk=None, tab='master', output=None): from emensageriapro.esocial.models import STATUS_EVENTO_CADASTRADO from emensageriapro.settings import VERSAO_EMENSAGERIA, VERSAO_LAYOUT_ESOCIAL TP_AMB = config.ESOCIAL_TP_AMB if pk: s2205_evtaltcadastral = get_object_or_404(s2205evtAltCadastral, id=pk) if request.user.has_perm('esocial.can_see_s2205evtAltCadastral'): if pk: s2205_evtaltcadastral_form = form_s2205_evtaltcadastral( request.POST or None, instance=s2205_evtaltcadastral, initial={'ativo': True}) else: s2205_evtaltcadastral_form = form_s2205_evtaltcadastral( request.POST or None, initial={ 'versao': VERSAO_LAYOUT_ESOCIAL, 'status': STATUS_EVENTO_CADASTRADO, 'tpamb': TP_AMB, 'procemi': 1, 'verproc': VERSAO_EMENSAGERIA, 'ativo': True }) if request.method == 'POST': if s2205_evtaltcadastral_form.is_valid(): obj = s2205_evtaltcadastral_form.save(request=request) messages.success(request, u'Salvo com sucesso!') if not pk: from emensageriapro.functions import identidade_evento identidade_evento(obj, 'esocial') if 'return_page' in request.session and request.session[ 'return_page'] and 's2205-evtaltcadastral' not in request.session[ 'return_page']: return HttpResponseRedirect(request.session['return_page']) if pk != obj.id: return redirect('s2205_evtaltcadastral_salvar', pk=obj.id) else: messages.error(request, u'Erro ao salvar!') s2205_evtaltcadastral_form = disabled_form_fields( s2205_evtaltcadastral_form, request.user.has_perm('esocial.change_s2205evtAltCadastral')) if pk: if s2205_evtaltcadastral.status != 0: s2205_evtaltcadastral_form = disabled_form_fields( s2205_evtaltcadastral_form, False) for field in s2205_evtaltcadastral_form.fields.keys(): s2205_evtaltcadastral_form.fields[field].widget.attrs[ 'ng-model'] = 's2205_evtaltcadastral_' + field if output: s2205_evtaltcadastral_form = disabled_form_for_print( s2205_evtaltcadastral_form) s2205_documentos_lista = None s2205_documentos_form = None s2205_brasil_lista = None s2205_brasil_form = None s2205_exterior_lista = None s2205_exterior_form = None s2205_trabestrangeiro_lista = None s2205_trabestrangeiro_form = None s2205_infodeficiencia_lista = None s2205_infodeficiencia_form = None s2205_dependente_lista = None s2205_dependente_form = None s2205_aposentadoria_lista = None s2205_aposentadoria_form = None s2205_contato_lista = None s2205_contato_form = None if pk: s2205_evtaltcadastral = get_object_or_404(s2205evtAltCadastral, id=pk) s2205_documentos_form = form_s2205_documentos( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_documentos_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_documentos_lista = s2205documentos.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_brasil_form = form_s2205_brasil( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_brasil_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_brasil_lista = s2205brasil.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_exterior_form = form_s2205_exterior( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_exterior_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_exterior_lista = s2205exterior.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_trabestrangeiro_form = form_s2205_trabestrangeiro( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_trabestrangeiro_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_trabestrangeiro_lista = s2205trabEstrangeiro.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_infodeficiencia_form = form_s2205_infodeficiencia( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_infodeficiencia_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_infodeficiencia_lista = s2205infoDeficiencia.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_dependente_form = form_s2205_dependente( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_dependente_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_dependente_lista = s2205dependente.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_aposentadoria_form = form_s2205_aposentadoria( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_aposentadoria_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_aposentadoria_lista = s2205aposentadoria.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_contato_form = form_s2205_contato( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}) s2205_contato_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_contato_lista = s2205contato.objects.\ filter(s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() else: s2205_evtaltcadastral = None tabelas_secundarias = [] controle_alteracoes = Auditoria.objects.filter( identidade=pk, tabela='s2205_evtaltcadastral').all() if not request.POST: request.session['return_page'] = request.META.get('HTTP_REFERER') context = { 'usuario': Usuarios.objects.get(user_id=request.user.id), 'pk': pk, 'output': output, 'evento_totalizador': False, 'controle_alteracoes': controle_alteracoes, 's2205_evtaltcadastral': s2205_evtaltcadastral, 's2205_evtaltcadastral_form': s2205_evtaltcadastral_form, 's2205_documentos_form': s2205_documentos_form, 's2205_documentos_lista': s2205_documentos_lista, 's2205_brasil_form': s2205_brasil_form, 's2205_brasil_lista': s2205_brasil_lista, 's2205_exterior_form': s2205_exterior_form, 's2205_exterior_lista': s2205_exterior_lista, 's2205_trabestrangeiro_form': s2205_trabestrangeiro_form, 's2205_trabestrangeiro_lista': s2205_trabestrangeiro_lista, 's2205_infodeficiencia_form': s2205_infodeficiencia_form, 's2205_infodeficiencia_lista': s2205_infodeficiencia_lista, 's2205_dependente_form': s2205_dependente_form, 's2205_dependente_lista': s2205_dependente_lista, 's2205_aposentadoria_form': s2205_aposentadoria_form, 's2205_aposentadoria_lista': s2205_aposentadoria_lista, 's2205_contato_form': s2205_contato_form, 's2205_contato_lista': s2205_contato_lista, 'data': datetime.datetime.now(), 'modulos': [ 'esocial', ], 'paginas': [ 's2205_evtaltcadastral', ], 'tabelas_secundarias': tabelas_secundarias, 'tab': tab, } if output == 'pdf': response = PDFTemplateResponse( request=request, template='s2205_evtaltcadastral_salvar.html', filename="s2205_evtaltcadastral.pdf", context=context, show_content_in_browser=True, cmd_options={ 'margin-top': 10, 'margin-bottom': 10, 'margin-right': 10, 'margin-left': 10, 'zoom': 1, 'dpi': 72, 'orientation': 'Landscape', "viewport-size": "1366 x 513", 'javascript-delay': 1000, 'footer-center': '[page]/[topage]', "no-stop-slow-scripts": True }, ) return response elif output == 'xls': response = render_to_response('s2205_evtaltcadastral_salvar.html', context) filename = "s2205_evtaltcadastral.xls" response[ 'Content-Disposition'] = 'attachment; filename=' + filename response[ 'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8' return response else: return render(request, 's2205_evtaltcadastral_salvar.html', context) else: context = { 'usuario': Usuarios.objects.get(user_id=request.user.id), 'pk': pk, 'tab': tab, 'output': output, 'modulos': [ 'esocial', ], 'paginas': [ 's2205_evtaltcadastral', ], 'data': datetime.datetime.now(), } return render(request, 'permissao_negada.html', context)
def salvar(request, hash): from emensageriapro.settings import VERSAO_EMENSAGERIA, VERSAO_LAYOUT_ESOCIAL, TP_AMB db_slug = 'default' try: usuario_id = request.user.id dict_hash = get_hash_url(hash) s2205_evtaltcadastral_id = int(dict_hash['id']) if 'tab' not in dict_hash.keys(): dict_hash['tab'] = '' for_print = int(dict_hash['print']) except: usuario_id = False return redirect('login') usuario = get_object_or_404(Usuarios.objects.using(db_slug), excluido=False, id=usuario_id) pagina = ConfigPaginas.objects.using(db_slug).get( excluido=False, endereco='s2205_evtaltcadastral') permissao = ConfigPermissoes.objects.using(db_slug).get( excluido=False, config_paginas=pagina, config_perfis=usuario.config_perfis) if s2205_evtaltcadastral_id: s2205_evtaltcadastral = get_object_or_404( s2205evtAltCadastral.objects.using(db_slug), excluido=False, id=s2205_evtaltcadastral_id) dict_permissoes = json_to_dict(usuario.config_perfis.permissoes) paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos if s2205_evtaltcadastral_id: if s2205_evtaltcadastral.status != 0: dict_permissoes['s2205_evtaltcadastral_apagar'] = 0 dict_permissoes['s2205_evtaltcadastral_editar'] = 0 if permissao.permite_visualizar: mensagem = None if s2205_evtaltcadastral_id: s2205_evtaltcadastral_form = form_s2205_evtaltcadastral( request.POST or None, instance=s2205_evtaltcadastral, slug=db_slug) else: s2205_evtaltcadastral_form = form_s2205_evtaltcadastral( request.POST or None, slug=db_slug, initial={ 'versao': VERSAO_LAYOUT_ESOCIAL, 'status': 0, 'processamento_codigo_resposta': 0, 'tpamb': TP_AMB, 'procemi': 1, 'verproc': VERSAO_EMENSAGERIA }) if request.method == 'POST': if s2205_evtaltcadastral_form.is_valid(): dados = s2205_evtaltcadastral_form.cleaned_data import json from django.forms.models import model_to_dict if s2205_evtaltcadastral_id: if s2205_evtaltcadastral.status == 0: dados['modificado_por_id'] = usuario_id dados['modificado_em'] = datetime.datetime.now() #s2205_evtaltcadastral_campos_multiple_passo1 s2205evtAltCadastral.objects.using(db_slug).filter( id=s2205_evtaltcadastral_id).update(**dados) obj = s2205evtAltCadastral.objects.using(db_slug).get( id=s2205_evtaltcadastral_id) #s2205_evtaltcadastral_editar_custom #s2205_evtaltcadastral_campos_multiple_passo2 messages.success(request, 'Alterado com sucesso!') gravar_auditoria( json.dumps(model_to_dict(s2205_evtaltcadastral), indent=4, sort_keys=True, default=str), json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 's2205_evtaltcadastral', s2205_evtaltcadastral_id, usuario_id, 2) else: obj = s2205evtAltCadastral.objects.using(db_slug).get( id=s2205_evtaltcadastral_id) messages.error( request, 'Não é possível salvar o evento, pois o mesmo não está com o status "Cadastrado"!' ) else: dados['processamento_codigo_resposta'] = '- -' dados['processamento_descricao_resposta'] = '- -' dados['criado_por_id'] = usuario_id dados['criado_em'] = datetime.datetime.now() dados['excluido'] = False #s2205_evtaltcadastral_cadastrar_campos_multiple_passo1 obj = s2205evtAltCadastral(**dados) obj.save(using=db_slug) #s2205_evtaltcadastral_cadastrar_custom #s2205_evtaltcadastral_cadastrar_campos_multiple_passo2 identidade_evento(obj.id, db_slug) messages.success(request, 'Cadastrado com sucesso!') s2205_evtaltcadastral_form = form_s2205_evtaltcadastral( request.POST or None, instance=obj, slug=db_slug) gravar_auditoria( '{}', json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 's2205_evtaltcadastral', obj.id, usuario_id, 1) if request.session['retorno_pagina'] not in ( 's2205_evtaltcadastral_apagar', 's2205_evtaltcadastral_salvar', 's2205_evtaltcadastral'): return redirect(request.session['retorno_pagina'], hash=request.session['retorno_hash']) if s2205_evtaltcadastral_id != obj.id: url_hash = base64.urlsafe_b64encode( '{"print": "0", "id": "%s"}' % (obj.id)) return redirect('s2205_evtaltcadastral_salvar', hash=url_hash) else: messages.error(request, 'Erro ao salvar!') s2205_evtaltcadastral_form = disabled_form_fields( s2205_evtaltcadastral_form, permissao.permite_editar) if s2205_evtaltcadastral_id: if s2205_evtaltcadastral.status != 0: s2205_evtaltcadastral_form = disabled_form_fields( s2205_evtaltcadastral_form, False) #s2205_evtaltcadastral_campos_multiple_passo3 for field in s2205_evtaltcadastral_form.fields.keys(): s2205_evtaltcadastral_form.fields[field].widget.attrs[ 'ng-model'] = 's2205_evtaltcadastral_' + field if int(dict_hash['print']): s2205_evtaltcadastral_form = disabled_form_for_print( s2205_evtaltcadastral_form) s2205_ctps_form = None s2205_ctps_lista = None s2205_ric_form = None s2205_ric_lista = None s2205_rg_form = None s2205_rg_lista = None s2205_rne_form = None s2205_rne_lista = None s2205_oc_form = None s2205_oc_lista = None s2205_cnh_form = None s2205_cnh_lista = None s2205_brasil_form = None s2205_brasil_lista = None s2205_exterior_form = None s2205_exterior_lista = None s2205_trabestrangeiro_form = None s2205_trabestrangeiro_lista = None s2205_infodeficiencia_form = None s2205_infodeficiencia_lista = None s2205_dependente_form = None s2205_dependente_lista = None s2205_aposentadoria_form = None s2205_aposentadoria_lista = None s2205_contato_form = None s2205_contato_lista = None if s2205_evtaltcadastral_id: s2205_evtaltcadastral = get_object_or_404( s2205evtAltCadastral.objects.using(db_slug), excluido=False, id=s2205_evtaltcadastral_id) s2205_ctps_form = form_s2205_ctps( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_ctps_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_ctps_lista = s2205CTPS.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_ric_form = form_s2205_ric( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_ric_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_ric_lista = s2205RIC.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_rg_form = form_s2205_rg( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_rg_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_rg_lista = s2205RG.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_rne_form = form_s2205_rne( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_rne_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_rne_lista = s2205RNE.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_oc_form = form_s2205_oc( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_oc_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_oc_lista = s2205OC.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_cnh_form = form_s2205_cnh( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_cnh_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_cnh_lista = s2205CNH.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_brasil_form = form_s2205_brasil( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_brasil_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_brasil_lista = s2205brasil.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_exterior_form = form_s2205_exterior( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_exterior_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_exterior_lista = s2205exterior.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_trabestrangeiro_form = form_s2205_trabestrangeiro( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_trabestrangeiro_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_trabestrangeiro_lista = s2205trabEstrangeiro.objects.using( db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_infodeficiencia_form = form_s2205_infodeficiencia( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_infodeficiencia_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_infodeficiencia_lista = s2205infoDeficiencia.objects.using( db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_dependente_form = form_s2205_dependente( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_dependente_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_dependente_lista = s2205dependente.objects.using( db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_aposentadoria_form = form_s2205_aposentadoria( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_aposentadoria_form.fields[ 's2205_evtaltcadastral'].widget.attrs['readonly'] = True s2205_aposentadoria_lista = s2205aposentadoria.objects.using( db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() s2205_contato_form = form_s2205_contato( initial={'s2205_evtaltcadastral': s2205_evtaltcadastral}, slug=db_slug) s2205_contato_form.fields['s2205_evtaltcadastral'].widget.attrs[ 'readonly'] = True s2205_contato_lista = s2205contato.objects.using(db_slug).filter( excluido=False, s2205_evtaltcadastral_id=s2205_evtaltcadastral.id).all() else: s2205_evtaltcadastral = None #s2205_evtaltcadastral_salvar_custom_variaveis# tabelas_secundarias = [] #[FUNCOES_ESPECIAIS_SALVAR] if 's2205_evtaltcadastral'[1] == '5': evento_totalizador = True else: evento_totalizador = False if not evento_totalizador: s2205_evtaltcadastral_form.fields['tpamb'].widget.attrs[ 'disabled'] = True s2205_evtaltcadastral_form.fields['tpamb'].widget.attrs[ 'readonly'] = True s2205_evtaltcadastral_form.fields['tpamb'].value = TP_AMB s2205_evtaltcadastral_form.fields['procemi'].widget.attrs[ 'disabled'] = True s2205_evtaltcadastral_form.fields['procemi'].widget.attrs[ 'readonly'] = True s2205_evtaltcadastral_form.fields['procemi'].value = 1 s2205_evtaltcadastral_form.fields['verproc'].widget.attrs[ 'readonly'] = True s2205_evtaltcadastral_form.fields[ 'verproc'].value = VERSAO_EMENSAGERIA if dict_hash['tab'] or 's2205_evtaltcadastral' in request.session[ 'retorno_pagina']: request.session["retorno_hash"] = hash request.session["retorno_pagina"] = 's2205_evtaltcadastral_salvar' controle_alteracoes = Auditoria.objects.using(db_slug).filter( identidade=s2205_evtaltcadastral_id, tabela='s2205_evtaltcadastral').all() context = { 'evento_totalizador': evento_totalizador, 'controle_alteracoes': controle_alteracoes, 's2205_evtaltcadastral': s2205_evtaltcadastral, 's2205_evtaltcadastral_form': s2205_evtaltcadastral_form, 'mensagem': mensagem, 's2205_evtaltcadastral_id': int(s2205_evtaltcadastral_id), 'usuario': usuario, 'hash': hash, 's2205_ctps_form': s2205_ctps_form, 's2205_ctps_lista': s2205_ctps_lista, 's2205_ric_form': s2205_ric_form, 's2205_ric_lista': s2205_ric_lista, 's2205_rg_form': s2205_rg_form, 's2205_rg_lista': s2205_rg_lista, 's2205_rne_form': s2205_rne_form, 's2205_rne_lista': s2205_rne_lista, 's2205_oc_form': s2205_oc_form, 's2205_oc_lista': s2205_oc_lista, 's2205_cnh_form': s2205_cnh_form, 's2205_cnh_lista': s2205_cnh_lista, 's2205_brasil_form': s2205_brasil_form, 's2205_brasil_lista': s2205_brasil_lista, 's2205_exterior_form': s2205_exterior_form, 's2205_exterior_lista': s2205_exterior_lista, 's2205_trabestrangeiro_form': s2205_trabestrangeiro_form, 's2205_trabestrangeiro_lista': s2205_trabestrangeiro_lista, 's2205_infodeficiencia_form': s2205_infodeficiencia_form, 's2205_infodeficiencia_lista': s2205_infodeficiencia_lista, 's2205_dependente_form': s2205_dependente_form, 's2205_dependente_lista': s2205_dependente_lista, 's2205_aposentadoria_form': s2205_aposentadoria_form, 's2205_aposentadoria_lista': s2205_aposentadoria_lista, 's2205_contato_form': s2205_contato_form, 's2205_contato_lista': s2205_contato_lista, 'modulos_permitidos_lista': modulos_permitidos_lista, 'paginas_permitidas_lista': paginas_permitidas_lista, 'permissao': permissao, 'data': datetime.datetime.now(), 'pagina': pagina, 'dict_permissoes': dict_permissoes, 'for_print': int(dict_hash['print']), 'tabelas_secundarias': tabelas_secundarias, 'tab': dict_hash['tab'], #s2205_evtaltcadastral_salvar_custom_variaveis_context# } if for_print in (0, 1): return render(request, 's2205_evtaltcadastral_salvar.html', context) elif for_print == 2: from wkhtmltopdf.views import PDFTemplateResponse response = PDFTemplateResponse( request=request, template='s2205_evtaltcadastral_salvar.html', filename="s2205_evtaltcadastral.pdf", context=context, show_content_in_browser=True, cmd_options={ 'margin-top': 10, 'margin-bottom': 10, 'margin-right': 10, 'margin-left': 10, 'zoom': 1, 'dpi': 72, 'orientation': 'Landscape', "viewport-size": "1366 x 513", 'javascript-delay': 1000, 'footer-center': '[page]/[topage]', "no-stop-slow-scripts": True }, ) return response elif for_print == 3: from django.shortcuts import render_to_response response = render_to_response('s2205_evtaltcadastral_salvar.html', context) filename = "s2205_evtaltcadastral.xls" response[ 'Content-Disposition'] = 'attachment; filename=' + filename response[ 'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8' return response else: context = { 'usuario': usuario, 'modulos_permitidos_lista': modulos_permitidos_lista, 'paginas_permitidas_lista': paginas_permitidas_lista, 'permissao': permissao, 'data': datetime.datetime.now(), 'pagina': pagina, 'dict_permissoes': dict_permissoes, } return render(request, 'permissao_negada.html', context)