本文整理汇总了Python中nimbus.shared.views.render_to_response函数的典型用法代码示例。如果您正苦于以下问题:Python render_to_response函数的具体用法?Python render_to_response怎么用?Python render_to_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_to_response函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: network
def network(request):
logger = logging.getLogger(__name__)
extra_context = {'wizard_title': u'2 de 4 - Configuração de Rede',
'page_name': u'network'}
if request.method == "GET":
interface = NetworkInterface.get_instance()
Form = form(NetworkInterface)
extra_context['form'] = Form(instance=interface)
return render_to_response( request, "generic.html", extra_context)
else:
edit_singleton_model(request, "generic.html",
"nimbus.wizard.views.timezone",
model = NetworkInterface,
extra_context = extra_context)
interface = NetworkInterface.get_instance()
if interface.address == get_raw_network_interface_address():
return redirect( "nimbus.wizard.views.timezone" )
else:
logger.info('redirecting user to redirect page')
return render_to_response(request, "redirect.html",
dict(ip_address=interface.address,
url=reverse('nimbus.wizard.views.timezone')))
示例2: add
def add(request, teste=None):
comp_id = 0
if request.GET:
comp_id = request.GET["comp_id"]
title = u"Adicionar backup"
form = ProcedureForm(prefix="procedure")
content = {'title': title,
'form':form,
'comp_id': comp_id}
if request.method == "POST":
data = copy(request.POST)
if data["procedure-fileset"]:
fileset = FileSet.objects.get(id=data['procedure-fileset'])
content['fileset'] = fileset
if data["procedure-schedule"]:
schedule = Schedule.objects.get(id=data['procedure-schedule'])
content['schedule'] = schedule
procedure_form = ProcedureForm(data, prefix="procedure")
if procedure_form.is_valid():
procedure = procedure_form.save()
messages.success(request, "Procedimento de backup '%s' criado com sucesso" % procedure.name)
return redirect('/procedures/list')
else:
messages.error(request, "O procedimento de backup não foi criado devido aos seguintes erros")
content['form'] = procedure_form
return render_to_response(request, "add_procedure.html", content)
return render_to_response(request, "add_procedure.html", content)
示例3: edit
def edit(request, procedure_id):
p = get_object_or_404(Procedure, pk=procedure_id)
title = u"Editando '%s'" % p.name
partial_form = ProcedureForm(prefix="procedure", instance=p)
content = {'title': title,
'form': partial_form,
'id': procedure_id,
'procedure': p,
'schedule': p.schedule,
'fileset': p.fileset,
'retention_time': p.pool_retention_time}
print content
print content['schedule'].id
if request.method == "POST":
data = copy(request.POST)
if data['procedure-schedule'] == u"":
data['procedure-schedule'] = u"%d" % p.schedule.id
if data['procedure-fileset'] == u"":
data['procedure-fileset'] = u"%d" % p.fileset.id
procedure_form = ProcedureForm(data, instance=p, prefix="procedure")
if procedure_form.is_valid():
procedure_form.save()
messages.success(request, "Procedimento '%s' alterado com sucesso" % p.name)
return redirect('/procedures/list')
else:
messages.error(request, "O procedimento de backup não foi criado devido aos seguintes erros")
content['forms'] = [procedure_form]
return render_to_response(request, "edit_procedure.html", content)
return render_to_response(request, 'edit_procedure.html', content)
示例4: about
def about(request):
version_file = settings.VERSION_FILE
with file(version_file) as f:
version_content = f.read().strip()
version, githash = version_content.split('-')
computers = len(Computer.objects.exclude(id=1))
all_procedures = Procedure.objects.exclude(id=1)
jobs = 0
for procedure in all_procedures:
jobs += len(procedure.all_my_good_jobs)
procedures = len(all_procedures)
try:
last_backup = Procedure.objects.get(id=1).last_success_date().endtime.strftime("%d/%m/%Y - %H:%M:%S")
except IndexError:
last_backup = "Não realizado"
data = {'computers': computers,
'procedures': procedures,
'jobs': jobs,
'last_backup': last_backup,
'version': version,
'release': githash
}
return render_to_response(request, "about.html", data)
示例5: delete
def delete(request, object_id):
c = get_object_or_404(Computer, pk=object_id)
jobs = c.all_my_jobs
content = {'computer': c,
'last_jobs': jobs,
'procedures': c.procedure_set.all()}
return render_to_response(request, "remove_computer.html", content)
示例6: add
def add(request):
lforms = [ forms.ComputerForm ]
content = {'title':u'Ativar novo Computador',
'forms':lforms,
'computers':Computer.objects.filter(active=False,id__gt=1)
}
return render_to_response(request, "computers_add.html", content)
示例7: list_uploadrequest
def list_uploadrequest(request):
uploads_requests = list(LocalUploadRequest.objects.all()) + list(RemoteUploadRequest.objects.all())
if 'ajax' in request.POST:
l = []
for up in uploads_requests:
d = {}
d['pk'] = up.id
# d['model'] = up.model
d['fields'] = {}
d['fields']['filename'] = up.volume.filename
d['fields']['created_at'] = up.created_at.strftime("%d/%m/%Y %H:%M")
d['fields']['attempts'] = up.attempts
if up.last_attempt:
d['fields']['last_attempt'] = up.last_attempt.strftime("%d/%m/%Y %H:%M")
else:
d['fields']['last_attempt'] = None
d['fields']['friendly_rate'] = up.friendly_rate
d['fields']['estimated_transfer_time'] = up.estimated_transfer_time
d['fields']['finished_percent'] = up.finished_percent
l.append(d)
# response = serializers.serialize("json", uploads_requests)
response = simplejson.dumps(l)
return HttpResponse(response, mimetype="text/plain")
return render_to_response(request,
"list_downuploadrequest.html",
{"object_list": uploads_requests,
"list_type": "Uploads",
"title": u"Uploads ativos"})
示例8: step3
def step3(request):
"""Selecionar o JOB"""
if request.method == "POST":
data = request.POST
computer = Computer.objects.get(id=data["computer_id"])
procedure = Procedure.objects.get(id=data["procedure_id"])
if data.has_key("start_date") and data.has_key("end_date"):
start_date = datetime.strptime(data["start_date"], "%d/%m/%Y")
end_date = datetime.strptime(data["end_date"] + " 23:59:59", "%d/%m/%Y %H:%M:%S")
jobs = procedure.get_backup_jobs_between(start_date, end_date)
else:
end_date = datetime.now()
start_date = datetime.today() - timedelta(30)
jobs = procedure.get_backup_jobs_between(start_date, end_date)
# jobs = procedure.all_my_good_jobs
extra_content = {
'computer': computer,
'procedure': procedure,
'jobs': jobs,
'start_date': start_date.strftime("%d/%m/%Y"),
'end_date': end_date.strftime("%d/%m/%Y"),
'title': u"Restauração de arquivos"
}
return render_to_response(request, "step3.html", extra_content)
else:
return redirect('nimbus.restore.views.step1')
示例9: list
def list(request):
d = {
"storages" : Storage.objects.filter(active=True),
"title": u"Armazenamento"
}
return render_to_response(request, "storages_list.html", d)
示例10: list_offsite
def list_offsite(request):
procedures = Procedure.with_job_tasks('Offsite')
last_jobs = Procedure.jobs_with_job_tasks('Offsite')
extra_content = {'procedures': procedures,
'last_jobs' : last_jobs,
'title': u"Procedimentos com offsite ativo"}
return render_to_response(request, "procedures_list.html", extra_content)
示例11: step1
def step1(request):
"""Selecionar o computador"""
computers = Computer.objects.filter(active=True,id__gt=1)
extra_content = {
'computers': computers,
'title': u"Restauração de arquivos"
}
return render_to_response(request, "step1.html", extra_content)
示例12: finish
def finish(request):
extra_content = {'title': u"Recuperação do sistema"}
if request.method == "GET":
return render_to_response(request, "recovery_finish.html", extra_content)
elif request.method == "POST":
wizard = Wizard.get_instance()
wizard.finish()
return redirect( "nimbus.base.views.home" )
示例13: select_storage
def select_storage(request):
if request.method == "GET":
extra_content = {'wizard_title': u'Selecione o armazenamento',
'title': u"Recuperação do sistema",
'devices' : offsite.list_disk_labels()}
return render_to_response(request, "recovery_select_storage.html",
extra_content)
else:
raise Http404()
示例14: view_computer
def view_computer(request, object_id):
storage = Storage.objects.get(id=object_id)
computers = Computer.objects.filter(procedure__profile__storage=storage)
d = {
"storage" : storage,
"computers" : computers,
"title": u'Computadores do armazenamento "%s"' % storage.name
}
return render_to_response(request, "computers_list.html", d)
示例15: profile_list
def profile_list(request):
title = u"Perfis de configuração"
filesets = FileSet.objects.filter(is_model=True)
schedules = Schedule.objects.filter(is_model=True)
computers = Computer.objects.filter(active=True,id__gt=1)
content = {'title': u"Perfis de configuração",
'filesets': filesets,
'schedules': schedules,
'computers': computers}
return render_to_response(request, "profile_list.html", content)