Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from builtins import str
2from builtins import object
3import logging
4import pyramid.httpexceptions as exc
5from pyramid.response import Response
6from pyramid.view import view_config, view_defaults
7from pyramid.httpexceptions import HTTPFound
8from marshall_webapp.templates.responses import templates_xmatches_catalogues
9from marshall_webapp.models.xmatches_catalogues.element import models_xmatches_element_catalogues_get, models_xmatches_element_catalogues_delete, models_xmatches_element_catalogues_put, models_xmatches_element_catalogues_post
10from dryxPyramid.views.views_base import base_view
11from venusian import lift
13# RESOURCE CONTEXT
15@view_defaults(route_name='xmatches_catalogues', permission="view_users")
16@lift()
17class views_xmatches_catalogues(base_view):
19 def __init__(self, request):
20 super().__init__(request)
21 self.resourceName = "xmatches_catalogues"
23 @view_config(request_method='GET', permission="view_users")
24 @view_config(request_param="method=get", permission="view_users")
25 def get(self):
27 xmatches_catalogues = templates_xmatches_catalogues(
28 log=self.log,
29 request=self.request
30 )
31 responseContent = xmatches_catalogues.get()
32 return Response(responseContent)
34# RESOURCE ELEMENT
36@view_defaults(route_name='xmatches_element_catalogues', permission="view_users")
37class xmatches_element_catalogues_view(object):
39 def __init__(self, request):
40 self.request = request
41 self.log = logging.getLogger(__name__)
42 self.log.debug(
43 "instantiating a new 'xmatches_catalogues' view")
45 @view_config(request_method='DELETE', permission="edit_users")
46 @view_config(request_param="method=delete", permission="edit_users")
47 def delete(self):
48 xmatches_catalogues = models_xmatches_element_catalogues_delete(
49 log=self.log,
50 request=self.request,
51 elementId=self.request.matchdict["elementId"]
52 )
53 responseContent = xmatches_catalogues.delete()
54 return Response(responseContent)
56 @view_config(request_method='PUT', permission="edit_users")
57 @view_config(request_param="method=put", permission="edit_users")
58 def put(self):
59 xmatches_catalogues = models_xmatches_element_catalogues_put(
60 log=self.log,
61 request=self.request,
62 elementId=self.request.matchdict["elementId"]
63 )
64 responseContent = xmatches_catalogues.put()
65 return Response(responseContent)
67 @view_config(request_method='POST', permission="edit_users")
68 @view_config(request_param="method=post", permission="edit_users")
69 def post(self):
70 xmatches_catalogues = models_xmatches_element_catalogues_post(
71 log=self.log,
72 request=self.request,
73 elementId=self.request.matchdict["elementId"]
74 )
75 thisResponse = xmatches_catalogues.post()
77 if "redirectURL" in self.request.params:
78 url = self.request.params["redirectURL"]
79 return HTTPFound(location=url)
80 else:
81 return Response(thisResponse)
83 @view_config(request_method='GET', request_param="format=json", renderer="json", permission="view_users")
84 @view_config(request_param=["method=get", "format=json"], renderer="json", permission="view_users")
85 def get_json(self):
86 xmatches_catalogues = templates_xmatches_catalogues(
87 log=self.log,
88 request=self.request,
89 elementId=self.request.matchdict["elementId"]
90 )
91 return xmatches_catalogues.get()
93 @view_config(request_method='GET', request_param="format=csv", renderer="csv", permission="view_users")
94 @view_config(request_param=["method=get", "format=csv"], renderer="csv", permission="view_users")
95 def get_csv(self):
96 xmatches_catalogues = models_xmatches_element_catalogues_get(
97 log=self.log,
98 request=self.request,
99 tcsCatalogueId=self.request.matchdict["elementId"]
100 )
101 return xmatches_catalogues.get()
103 @view_config(request_method='GET', request_param="format=plain_table", renderer="plain_table", permission="view_users")
104 @view_config(request_param=["method=get", "format=plain_table"], renderer="plain_table", permission="view_users")
105 def get_plain_table(self):
106 xmatches_catalogues = models_xmatches_element_catalogues_get(
107 log=self.log,
108 request=self.request,
109 tcsCatalogueId=self.request.matchdict["elementId"]
110 )
111 return xmatches_catalogues.get()
113 @view_config(request_method='GET', permission="view_users")
114 @view_config(request_param="method=get", permission="view_users")
115 def get(self):
116 xmatches_catalogues = templates_xmatches_catalogues(
117 log=self.log,
118 request=self.request,
119 elementId=self.request.matchdict["elementId"]
120 )
122 return Response(str(xmatches_catalogues.get()))