本文整理汇总了Python中tardis.tardis_portal.shortcuts.render_response_index函数的典型用法代码示例。如果您正苦于以下问题:Python render_response_index函数的具体用法?Python render_response_index怎么用?Python render_response_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_response_index函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_par
def add_par(request, parentObject, otype, stype):
all_schema = Schema.objects.filter(type=stype, immutable=False)
if 'schema_id' in request.GET:
schema_id = request.GET['schema_id']
elif all_schema.count() > 0:
schema_id = all_schema[0].id
else:
return HttpResponse(render_response_index(
request, 'tardis_portal/ajax/parameter_set_unavailable.html', {}))
schema = Schema.objects.get(id=schema_id)
parameternames = ParameterName.objects.filter(
schema__namespace=schema.namespace)
success = False
valid = True
if request.method == 'POST':
request = remove_csrf_token(request)
class DynamicForm(create_datafile_add_form(
schema.namespace, parentObject, request=request)):
pass
form = DynamicForm(request.POST)
if form.is_valid():
save_datafile_add_form(schema.namespace, parentObject, request)
success = True
else:
valid = False
else:
class DynamicForm(create_datafile_add_form(
schema.namespace, parentObject)):
pass
form = DynamicForm()
c = {
'schema': schema,
'form': form,
'parameternames': parameternames,
'type': otype,
'success': success,
'valid': valid,
'parentObject': parentObject,
'all_schema': all_schema,
'schema_id': schema.id,
}
return HttpResponse(render_response_index(request,
'tardis_portal/ajax/parameteradd.html', c))
开发者ID:keithschulze,项目名称:mytardis,代码行数:58,代码来源:parameters.py
示例2: auth_exp_publish
def auth_exp_publish(request):
"""
Check the provided authcode against outstanding experiments awaiting
authorisation and if match, then give authorisation.
:param request: the web request
:type request: :class:`django.http.HttpRequest`
"""
context = {}
if request.method == "GET":
exp_id = None
if "expid" in request.GET:
exp_id = request.GET["expid"]
else:
context[u"message"] = u"Unknown experiment"
return HttpResponse(render_response_index(request, u"hpctardis/authorise_publish.html", Context(context)))
try:
experiment = Experiment.objects.get(id=exp_id)
except Experiment.DoesNotExist:
context[u"message"] = u"Unknown experiment"
return HttpResponse(render_response_index(request, "hpctardis/authorise_publish.html", Context(context)))
if experiment.public:
context[u"message"] = u"Experiment already public"
return HttpResponse(render_response_index(request, "hpctardis/authorise_publish.html", Context(context)))
if "authcode" in request.GET:
authcode = request.GET["authcode"]
else:
context[u"message"] = u"bad authcode"
return HttpResponse(render_response_index(request, "hpctardis/authorise_publish.html", Context(context)))
auths = PublishAuthorisation.objects.filter(auth_key=authcode, experiment=experiment)
for auth in auths:
if auth.status == PublishAuthorisation.PENDING_APPROVAL:
if authcode == auth.auth_key:
auth.status = PublishAuthorisation.APPROVED_PUBLIC
auth.date_authorised = datetime.datetime.now()
auth.save()
context[u"message"] = u"Thank you for your approval %s" % auth.party_record
break
elif auth.status == PublishAuthorisation.APPROVED_PUBLIC:
if authcode == auth.auth_key:
context[u"message"] = u"Already authorised"
break
else:
context[u"message"] = u"unknown command %s" % auth.status
# TODO: send message to original owner if exp now public
_ = _promote_experiments_to_public(experiment)
return HttpResponse(render_response_index(request, "hpctardis/authorise_publish.html", Context(context)))
开发者ID:aaryani,项目名称:CoreTardis,代码行数:56,代码来源:views.py
示例3: index
def index(request, experiment_id):
url = 'monash_ands/form.html'
try:
e = Experiment.objects.get(id=experiment_id)
import sys
allowed_protocol = sys.modules['%s.%s.settings' %
(settings.TARDIS_APP_ROOT, 'monash_ands')].ALLOWED_PROTOCOL
if not request.user.is_authenticated():
# todo: de-duplicate
from django.template import Context
c = Context()
c['disallowed_protocol'] = True
return HttpResponse(render_response_index(request, url, c))
ua = UserAuthentication.objects.get(username=request.user.username)
if not ua.authenticationMethod == allowed_protocol:
from django.template import Context
c = Context()
c['is_owner'] = authz.has_experiment_ownership(request,
experiment_id)
c['disallowed_protocol'] = True
return HttpResponse(render_response_index(request, url, c))
if not request.POST:
monashandsService = MonashANDSService(experiment_id)
c = monashandsService.get_context(request)
if request.user.is_authenticated():
c['is_owner'] = authz.has_experiment_ownership(request,
experiment_id)
c['experiment'] = e
cch = CreativeCommonsHandler(experiment_id=experiment_id, create=False)
c['has_cc_license'] = cch.has_cc_license()
return HttpResponse(render_response_index(request, url, c))
else:
monashandsService = MonashANDSService(experiment_id)
c = monashandsService.register(request)
if request.user.is_authenticated():
c['is_owner'] = authz.has_experiment_ownership(request,
experiment_id)
c['experiment'] = e
return HttpResponse(render_response_index(request, url, c))
except Exception, e:
# todo: check with web services for adequate responses..
message = '<b>An error occured:</b> ' + str(e)
return HttpResponse(content=message)
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:55,代码来源:views.py
示例4: add_par
def add_par(request, parentObject, otype, stype):
all_schema = Schema.objects.filter(type=stype, immutable=False)
if "schema_id" in request.GET:
schema_id = request.GET["schema_id"]
elif all_schema.count() > 0:
schema_id = all_schema[0].id
else:
return HttpResponse(render_response_index(request, "tardis_portal/ajax/parameter_set_unavailable.html", {}))
schema = Schema.objects.get(id=schema_id)
parameternames = ParameterName.objects.filter(schema__namespace=schema.namespace)
success = False
valid = True
if request.method == "POST":
request = remove_csrf_token(request)
class DynamicForm(create_datafile_add_form(schema.namespace, parentObject, request=request)):
pass
form = DynamicForm(request.POST)
if form.is_valid():
save_datafile_add_form(schema.namespace, parentObject, request)
success = True
else:
valid = False
else:
class DynamicForm(create_datafile_add_form(schema.namespace, parentObject)):
pass
form = DynamicForm()
c = {
"schema": schema,
"form": form,
"parameternames": parameternames,
"type": otype,
"success": success,
"valid": valid,
"parentObject": parentObject,
"all_schema": all_schema,
"schema_id": schema.id,
}
return HttpResponse(render_response_index(request, "tardis_portal/ajax/parameteradd.html", c))
开发者ID:grischa,项目名称:mytardis,代码行数:53,代码来源:parameters.py
示例5: create_user
def create_user(request):
if 'user' not in request.POST:
c = {'createUserPermissionsForm':
CreateUserPermissionsForm()}
response = HttpResponse(render_response_index(
request,
'tardis_portal/ajax/create_user.html', c))
return response
authMethod = localdb_auth_key
if 'user' in request.POST:
username = request.POST['user']
if 'authMethod' in request.POST:
authMethod = request.POST['authMethod']
if 'email' in request.POST:
email = request.POST['email']
if 'password' in request.POST:
password = request.POST['password']
try:
with transaction.atomic():
validate_email(email)
user = User.objects.create_user(username, email, password)
authentication = UserAuthentication(userProfile=user.userprofile,
username=username,
authenticationMethod=authMethod)
authentication.save()
except ValidationError:
return HttpResponse('Could not create user %s '
'(Email address is invalid: %s)' %
(username, email), status=403)
except: # FIXME
return HttpResponse(
'Could not create user %s '
'(It is likely that this username already exists)' %
(username), status=403)
c = {'user_created': username}
transaction.commit()
response = HttpResponse(render_response_index(
request,
'tardis_portal/ajax/create_user.html', c))
return response
开发者ID:jasonrig,项目名称:mytardis,代码行数:52,代码来源:authentication.py
示例6: login
def login(request):
'''
handler for login page
'''
from tardis.tardis_portal.auth import auth_service
if request.user.is_authenticated():
# redirect the user to the home page if he is trying to go to the
# login page
return HttpResponseRedirect(request.POST.get('next_page', '/'))
# TODO: put me in SETTINGS
if 'username' in request.POST and \
'password' in request.POST:
authMethod = request.POST.get('authMethod', None)
user = auth_service.authenticate(
authMethod=authMethod, request=request)
if user:
next_page = request.POST.get(
'next_page', request.GET.get('next_page', '/'))
user.backend = 'django.contrib.auth.backends.ModelBackend'
djauth.login(request, user)
return HttpResponseRedirect(next_page)
c = {'status': "Sorry, username and password don't match.",
'error': True,
'loginForm': LoginForm()}
return HttpResponseForbidden(
render_response_index(request, 'tardis_portal/login.html', c))
url = request.META.get('HTTP_REFERER', '/')
u = urlparse(url)
if u.netloc == request.META.get('HTTP_HOST', ""):
next_page = u.path
else:
next_page = '/'
c = {'loginForm': LoginForm(),
'next_page': next_page}
c['RAPID_CONNECT_ENABLED'] = settings.RAPID_CONNECT_ENABLED
c['RAPID_CONNECT_LOGIN_URL'] = settings.RAPID_CONNECT_CONFIG[
'authnrequest_url']
return HttpResponse(render_response_index(request,
'tardis_portal/login.html', c))
开发者ID:jasonrig,项目名称:mytardis,代码行数:48,代码来源:authentication.py
示例7: user_guide
def user_guide(request):
c = {
'user_guide_location': getattr(
settings, 'CUSTOM_USER_GUIDE', 'user_guide/index.html'),
}
return HttpResponse(render_response_index(request,
'tardis_portal/user_guide.html', c))
开发者ID:keithschulze,项目名称:mytardis,代码行数:7,代码来源:pages.py
示例8: display_datafile_details
def display_datafile_details(request, datafile_id):
"""
Displays a box, with a list of interaction options depending on
the file type given and displays the one with the highest priority
first.
Views are set up in settings. Order of list is taken as priority.
Given URLs are called with the datafile id appended.
"""
# retrieve valid interactions for file type
the_file = DataFile.objects.get(id=datafile_id)
the_schemas = [p.schema.namespace for p in the_file.getParameterSets()]
default_view = "Datafile Metadata"
apps = [
(default_view, '/ajax/parameters'), ]
if hasattr(settings, "DATAFILE_VIEWS"):
apps += settings.DATAFILE_VIEWS
views = []
for ns, url in apps:
if ns == default_view:
views.append({"url": "%s/%s/" % (url, datafile_id),
"name": default_view})
elif ns in the_schemas:
schema = Schema.objects.get(namespace__exact=ns)
views.append({"url": "%s/%s/" % (url, datafile_id),
"name": schema.name})
context = {
'datafile_id': datafile_id,
'views': views,
}
return HttpResponse(render_response_index(
request,
"tardis_portal/ajax/datafile_details.html",
context))
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:34,代码来源:ajax_pages.py
示例9: partners
def partners(request):
c = Context({'subtitle': 'Partners',
'about_pressed': True,
'nav': [{'name': 'Partners', 'link': '/partners/'}]})
return HttpResponse(render_response_index(request,
'tardis_portal/partners.html', c))
开发者ID:IntersectAustralia,项目名称:dc2c,代码行数:7,代码来源:views.py
示例10: mydetails
def mydetails(request):
c = Context()
existing_details = OwnerDetails.objects.filter(user=request.user)
if existing_details.count() == 1:
owner_details = existing_details[0]
else:
owner_details = None
if request.method == 'POST':
form = OwnerDetailsForm(request.POST, instance=owner_details)
if form.is_valid():
form.save()
request.POST = {'status': 'Details Saved'}
c['status'] = 'Details Saved'
else:
c['status'] = "Errors exist in form."
c["error"] = 'true'
#return redirect(reverse('tardis.tardis_portal.views.experiment_index'))
else:
if not owner_details:
owner_details = OwnerDetails(user=request.user,
first_name=request.user.first_name,
last_name=request.user.last_name,
email=request.user.email)
form = OwnerDetailsForm(instance=owner_details)
c['form'] = form
return HttpResponse(render_response_index(request,
'tardis_portal/rif-cs/mydetails.html', c))
开发者ID:IntersectAustralia,项目名称:dc2c,代码行数:28,代码来源:views.py
示例11: get
def get(self, request, *args, **kwargs):
"""
The index view, intended to render the front page of the MyTardis site
listing recent experiments.
This default view can be overriden by defining a dictionary INDEX_VIEWS in
settings which maps SITE_ID's or domain names to an alternative view
function (similar to the DATASET_VIEWS or EXPERIMENT_VIEWS overrides).
:param request: a HTTP request object
:type request: :class:`django.http.HttpRequest`
:return: The Django response object
:rtype: :class:`django.http.HttpResponse`
"""
dataset_id = kwargs.get('dataset_id', None)
if dataset_id is None:
return return_response_error(request)
dataset = Dataset.objects.get(id=dataset_id)
if not dataset:
return return_response_not_found(request)
view_override = self.find_custom_view_override(request, dataset)
if view_override is not None:
return view_override
c = self.get_context_data(request, dataset, **kwargs)
template_name = kwargs.get('template_name', None)
if template_name is None:
template_name = self.template_name
return HttpResponse(render_response_index(request, template_name, c))
开发者ID:nrmay,项目名称:mytardis,代码行数:34,代码来源:pages.py
示例12: edit_sample
def edit_sample(request, experiment_id, sample_id):
try:
experiment = Experiment.safe.get(request, experiment_id)
except PermissionDenied:
return return_response_error(request)
except Experiment.DoesNotExist:
return return_response_not_found(request)
c = Context()
c['experiment'] = experiment
sample = Sample.objects.get(id=sample_id)
c['sample_count'] = sample.name
if request.POST:
form = SampleForm(request.POST, instance=sample, extra=0)
if form.is_valid():
full_sample = form.save(experiment_id, commit=False)
full_sample.save_m2m()
request.POST = {'status': "Sample Created."}
return _redirect(experiment_id)
c['status'] = "Errors exist in form."
c["error"] = 'true'
else:
form = SampleForm(instance=sample, extra=0)
c['form'] = form
c['status'] = form.errors
return HttpResponse(render_response_index(request,
'tardis_portal/experiment_sample.html', c))
开发者ID:IntersectAustralia,项目名称:dc2c,代码行数:29,代码来源:views.py
示例13: get
def get(self, request, *args, **kwargs):
"""
:param request: a HTTP request object
:type request: :class:`django.http.HttpRequest`
:return: The Django response object
:rtype: :class:`django.http.HttpResponse`
"""
dataset_id = kwargs.get('dataset_id', None)
if dataset_id is None:
return return_response_error(request)
dataset = Dataset.objects.get(id=dataset_id)
if not dataset:
return return_response_not_found(request)
c = self.get_context_data(request, dataset, **kwargs)
template_name = kwargs.get('template_name', None)
if template_name is None:
template_name = self.template_name
return HttpResponse(render_response_index(
request,
template_name,
c)
)
开发者ID:mytardis,项目名称:mytardis-seqfac,代码行数:29,代码来源:views.py
示例14: search_quick
def search_quick(request):
get = False
experiments = Experiment.objects.all().order_by('title')
if 'results' in request.GET:
get = True
if 'quicksearch' in request.GET \
and len(request.GET['quicksearch']) > 0:
experiments = \
experiments.filter(
title__icontains=request.GET['quicksearch']) | \
experiments.filter(
institution_name__icontains=request.GET['quicksearch']) | \
experiments.filter(
experimentauthor__author__name__icontains=request.GET[
'quicksearch']) | \
experiments.filter(
pdbid__pdbid__icontains=request.GET['quicksearch'])
experiments = experiments.distinct()
logger.debug(experiments)
c = {'submitted': get, 'experiments': experiments,
'subtitle': 'Search Experiments'}
return HttpResponse(render_response_index(request,
'tardis_portal/search_experiment.html', c))
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:27,代码来源:views.py
示例15: view_rifcs
def view_rifcs(request, experiment_id):
"""View the rif-cs of an existing experiment.
:param request: a HTTP Request instance
:type request: :class:`django.http.HttpRequest`
:param experiment_id: the ID of the experiment to be viewed
:type experiment_id: string
:rtype: :class:`django.http.HttpResponse`
"""
try:
experiment = Experiment.safe.get(request.user, experiment_id)
except PermissionDenied:
return return_response_error(request)
except Experiment.DoesNotExist:
return return_response_not_found(request)
try:
rifcs_provs = settings.RIFCS_PROVIDERS
except AttributeError:
rifcs_provs = ()
from tardis.tardis_portal.publish.publishservice import PublishService
pservice = PublishService(rifcs_provs, experiment)
context = pservice.get_context()
if context is None:
# return error page or something
return return_response_error(request)
template = pservice.get_template()
return HttpResponse(render_response_index(request,
template, context), content_type="text/xml")
开发者ID:IntersectAustralia,项目名称:mytardis,代码行数:32,代码来源:machine.py
示例16: share
def share(request, experiment_id):
'''
Choose access rights and licence.
'''
experiment = Experiment.objects.get(id=experiment_id)
user = request.user
c = {}
c['has_write_permissions'] = \
authz.has_write_permissions(request, experiment_id)
c['has_download_permissions'] = \
authz.has_experiment_download_access(request, experiment_id)
if user.is_authenticated():
c['is_owner'] = authz.has_experiment_ownership(request, experiment_id)
c['is_superuser'] = user.is_superuser
c['is_staff'] = user.is_staff
domain = Site.objects.get_current().domain
public_link = experiment.public_access >= Experiment.PUBLIC_ACCESS_METADATA
c['experiment'] = experiment
c['public_link'] = public_link
c['domain'] = domain
return HttpResponse(render_response_index(request,
'tardis_portal/ajax/share.html', c))
开发者ID:jasonrig,项目名称:mytardis,代码行数:27,代码来源:authorisation.py
示例17: return_response_datafile_private
def return_response_datafile_private(request,exp):
c = Context({'exp_id':exp.id,
'exp_name':exp.title,
'owner_name':exp.created_by.get_full_name(),
'owner_email': exp.created_by.email})
return HttpResponseNotFound(render_response_index(request,
'hpctardis/contact_download.html', c))
开发者ID:aaryani,项目名称:CoreTardis,代码行数:7,代码来源:download.py
示例18: new_sample
def new_sample(request, experiment_id):
try:
experiment = Experiment.safe.get(request, experiment_id)
except PermissionDenied:
return return_response_error(request)
except Experiment.DoesNotExist:
return return_response_not_found(request)
c = Context()
c['experiment'] = experiment
samples = Sample.objects.filter(experiment=experiment_id)
c['sample_count'] = samples.count() + 1
if request.method == 'POST':
form = SampleForm(request.POST)
if form.is_valid():
sample = form.save(experiment_id, commit=False)
sample.save_m2m()
request.POST = {'status': "Sample Created."}
return _redirect(experiment_id)
c['status'] = "Errors exist in form."
c["error"] = 'true'
else:
form = SampleForm(extra=1)
c['form'] = form
c['status'] = form.errors
return HttpResponse(render_response_index(request,
'tardis_portal/experiment_sample.html', c))
开发者ID:IntersectAustralia,项目名称:dc2c,代码行数:29,代码来源:views.py
示例19: index
def index(request):
c = Context({'form': EmbargoSearchForm(),
'subtitle': 'Embargo Periods',
'searched': False,
'header': 'Register Metaman File'})
return HttpResponse(render_response_index(request, 'tardis_portal/embargo_index.html', c))
开发者ID:aaryani,项目名称:aa-migration-test1,代码行数:7,代码来源:embargo.py
示例20: retrieve_access_list_user_readonly
def retrieve_access_list_user_readonly(request, experiment_id):
user_acls = Experiment.safe.user_acls(experiment_id)
c = {'user_acls': user_acls, 'experiment_id': experiment_id}
return HttpResponse(
render_response_index(
request, 'tardis_portal/ajax/access_list_user_readonly.html', c))
开发者ID:jasonrig,项目名称:mytardis,代码行数:7,代码来源:authorisation.py
注:本文中的tardis.tardis_portal.shortcuts.render_response_index函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论