def download(request): if request.method == 'POST': # If the form has been submitted... # ContactForm was defined in the the previous section form = ExportForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Get the creds to export creds = Cred.objects.accessible(request.user) # Make the Audit logs auditlogs = [] for c in creds: auditlogs.append(CredAudit( audittype=CredAudit.CREDEXPORT, cred=c, user=request.user, )) # Create all Audit logs at once CredAudit.objects.bulk_create(auditlogs) # Give the Keepass file to the user return export_keepass(creds, form.cleaned_data['password']) else: form = ExportForm() # An unbound form return render(request, 'cred_export.html', { 'form': form, })
def download(request): if request.method == 'POST': # If the form has been submitted... # ContactForm was defined in the the previous section form = ExportForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Get the creds to export creds = Cred.objects.accessible(request.user) # Make the Audit logs auditlogs = [] for c in creds: auditlogs.append( CredAudit( audittype=CredAudit.CREDEXPORT, cred=c, user=request.user, )) # Create all Audit logs at once CredAudit.objects.bulk_create(auditlogs) # Give the Keepass file to the user return export_keepass(creds, form.cleaned_data['password']) else: form = ExportForm() # An unbound form return render(request, 'cred_export.html', { 'form': form, })
def download(request, cfilter="special", value="all"): if request.method == 'POST': # If the form has been submitted... form = ExportForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Get the creds to export (search_object, creds) = cred_search(request.user, cfilter, value) filename = 'RatticExport.kdb' # Decide on the filename if cfilter == 'tag': filename = 'RatticExportTag-%s.kdb' % search_object.name elif cfilter == 'group': filename = 'RatticExportGroup-%s.kdb' % search_object.name elif cfilter == 'search': filename = 'RatticExportSearch-%s.kdb' % search_object elif cfilter == 'special' and value == 'all': filename = 'RatticExportAll.kdb' elif cfilter == 'special' and value == 'trash': filename = 'RatticExportTrash.kdb' else: raise Http404 # Make the Audit logs auditlogs = [] for c in creds: auditlogs.append( CredAudit( audittype=CredAudit.CREDEXPORT, cred=c, user=request.user, )) # Create all Audit logs at once CredAudit.objects.bulk_create(auditlogs) # Give the Keepass file to the user return export_keepass(creds, form.cleaned_data['password'], filename) else: form = ExportForm() # An unbound form return render(request, 'cred_export.html', { 'form': form, })
def download(request, cfilter="special", value="all"): if request.method == 'POST': # If the form has been submitted... form = ExportForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Get the creds to export (search_object, creds) = cred_search(request.user, cfilter, value) filename = 'RatticExport.kdb' # Decide on the filename if cfilter == 'tag': filename = 'RatticExportTag-%s.kdb' % search_object.name elif cfilter == 'group': filename = 'RatticExportGroup-%s.kdb' % search_object.name elif cfilter == 'search': filename = 'RatticExportSearch-%s.kdb' % search_object elif cfilter == 'special' and value == 'all': filename = 'RatticExportAll.kdb' elif cfilter == 'special' and value == 'trash': filename = 'RatticExportTrash.kdb' else: raise Http404 # Make the Audit logs auditlogs = [] for c in creds: auditlogs.append(CredAudit( audittype=CredAudit.CREDEXPORT, cred=c, user=request.user, )) # Create all Audit logs at once CredAudit.objects.bulk_create(auditlogs) # Give the Keepass file to the user return export_keepass(creds, form.cleaned_data['password'], filename) else: form = ExportForm() # An unbound form return render(request, 'cred_export.html', { 'form': form, })