impersonate

parent 492dc574
...@@ -45,6 +45,7 @@ INSTALLED_APPS = [ ...@@ -45,6 +45,7 @@ INSTALLED_APPS = [
'administration.apps.AdministrationConfig', 'administration.apps.AdministrationConfig',
'users.apps.UsersConfig', 'users.apps.UsersConfig',
'django_extensions', 'django_extensions',
'impersonate'
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -53,9 +54,11 @@ MIDDLEWARE = [ ...@@ -53,9 +54,11 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'impersonate.middleware.ImpersonateMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'catalog.middleware.AuthRequiredMiddleware', 'catalog.middleware.AuthRequiredMiddleware',
] ]
ROOT_URLCONF = 'GeoInt_SIDT.urls' ROOT_URLCONF = 'GeoInt_SIDT.urls'
......
...@@ -31,5 +31,6 @@ urlpatterns = [ ...@@ -31,5 +31,6 @@ urlpatterns = [
url(r'^mail/', include('mail.urls')), url(r'^mail/', include('mail.urls')),
url(r'^administration/', include('administration.urls')), url(r'^administration/', include('administration.urls')),
url(r'^users/', include('users.urls')), url(r'^users/', include('users.urls')),
url(r'^impersonate/', include('impersonate.urls')),
] ]
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
...@@ -164,6 +164,10 @@ ...@@ -164,6 +164,10 @@
{% if user.superuser == True %}checked{% endif %}> {% if user.superuser == True %}checked{% endif %}>
</td> </td>
<td> <td>
{% if not user.superuser and request.user.is_superuser %}
<a title="swithc user" href="{% url 'impersonate-start' user.user_id %}" class="btn btn-warning"><i
class="fa fa-eye"></i></a>
{% endif %}
<button title="save" type="submit" class="btn btn-success"><i <button title="save" type="submit" class="btn btn-success"><i
class="fa fa-save"></i></button> class="fa fa-save"></i></button>
{% if Viewname != "Request" %} {% if Viewname != "Request" %}
......
...@@ -15,6 +15,7 @@ class AuthRequiredMiddleware(object): ...@@ -15,6 +15,7 @@ class AuthRequiredMiddleware(object):
# the view (and later middleware) are called. # the view (and later middleware) are called.
response = self.get_response(request) response = self.get_response(request)
print ('midleware response',response)
if "/reports/" in request.path_info and not request.user.is_authenticated: if "/reports/" in request.path_info and not request.user.is_authenticated:
...@@ -33,12 +34,17 @@ class AuthRequiredMiddleware(object): ...@@ -33,12 +34,17 @@ class AuthRequiredMiddleware(object):
#elif not request.user.is_authenticated and request.path_info == reverse('tile') or request.path_info == reverse('tileinfo') : #elif not request.user.is_authenticated and request.path_info == reverse('tile') or request.path_info == reverse('tileinfo') :
# return response # return response
elif "/impersonate/" in request.path_info:
return response
elif request.path_info == reverse('ipn'): elif request.path_info == reverse('ipn'):
return response return response
elif not request.user.is_authenticated and request.path_info != reverse('login') and not request.user.is_active: elif not request.user.is_authenticated and request.path_info != reverse('login') and not request.user.is_active:
return HttpResponseRedirect(reverse('login')) return HttpResponseRedirect(reverse('login'))
# Code to be executed for each request/response after # Code to be executed for each request/response after
# the view is called. # the view is called.
print ('user', request.user)
return response return response
...@@ -32,13 +32,14 @@ ...@@ -32,13 +32,14 @@
{% block headMedia %}{% endblock %} {% block headMedia %}{% endblock %}
<link rel="stylesheet" href="{% static 'catalog/adminlte/bower_components/guides-master/dist/guides.css' %}"> <link rel="stylesheet" href="{% static 'catalog/adminlte/bower_components/guides-master/dist/guides.css' %}">
<link rel="stylesheet" href="{% static 'catalog/css/base_top.css' %}">
</head> </head>
<body style="overflow: hidden;" class="hold-transition skin-yellow sidebar-mini"> <body style="overflow: hidden;" class="hold-transition skin-yellow sidebar-mini">
<!-- <div id="map" class="map" tabindex="0"> </div>--> <!-- <div id="map" class="map" tabindex="0"> </div>-->
<!-- <iframe id="catalogFrame" name="catalogFrame">my frame</iframe>--> <!-- <iframe id="catalogFrame" name="catalogFrame">my frame</iframe>-->
<div class="wrmapper"> <div class="wrmapper">
<header class="main-header"> <header class="main-header">
<!-- Logo --> <!-- Logo -->
<a {% if request.user.is_authenticated %}href="{{ BASE_URL }}/catalog" {% else %} <a {% if request.user.is_authenticated %}href="{{ BASE_URL }}/catalog" {% else %}
...@@ -51,6 +52,7 @@ ...@@ -51,6 +52,7 @@
</a> </a>
<!-- Header Navbar: style can be found in header.less --> <!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top"> <nav class="navbar navbar-static-top">
<!-- Sidebar toggle button--> <!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button"> <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
...@@ -110,7 +112,10 @@ ...@@ -110,7 +112,10 @@
</div> </div>
{% endif %} {% endif %}
</nav> </nav>
</header> </header>
<!-- Left side column. contains the logo and sidebar --> <!-- Left side column. contains the logo and sidebar -->
<aside class="main-sidebar"> <aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less --> <!-- sidebar: style can be found in sidebar.less -->
...@@ -124,7 +129,15 @@ ...@@ -124,7 +129,15 @@
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<div class="content-wrapper" style="border:0px solid blue;"> <div class="content-wrapper" style="border:0px solid blue;">
{% block content %}{% endblock %} {% if user.is_impersonate %}
<div class="alert alert2 alert-dismissible " >
<a href="{% url 'impersonate-stop' %}" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<strong>View as: </strong> {{ user.get_full_name }}
</div>
{% endif %}
{% block content %}
{% endblock %}
{% block templates %}{% endblock %} {% block templates %}{% endblock %}
</div> </div>
<!-- /.content-wrapper --> <!-- /.content-wrapper -->
...@@ -228,36 +241,36 @@ ...@@ -228,36 +241,36 @@
</div> </div>
<!-- control para dibujar el poligono --> <!-- control para dibujar el poligono -->
</div> </div>
</div> </div>
<!-- ./wrapper --> <!-- ./wrapper -->
<!-- T E M P L A T E S --> <!-- T E M P L A T E S -->
<!-- T E M P L A T E S --> <!-- T E M P L A T E S -->
<!-- MODAL 1 --> <!-- MODAL 1 -->
{% block modals %}{% endblock %} {% block modals %}{% endblock %}
<!-- MODAL 1 --> <!-- MODAL 1 -->
<!-- Bootstrap 3.3.7 --> <!-- Bootstrap 3.3.7 -->
<script src="{% static 'catalog/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js' %}"></script> <script src="{% static 'catalog/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js' %}"></script>
<!-- AdminLTE App --> <!-- AdminLTE App -->
<script src="{% static 'catalog/adminlte/dist/js/adminlte.min.js' %}"></script> <script src="{% static 'catalog/adminlte/dist/js/adminlte.min.js' %}"></script>
<!-- Data management file --> <!-- Data management file -->
<script src="{% static 'catalog/js/dataRetrieval.js' %}" type="text/javascript"></script> <script src="{% static 'catalog/js/dataRetrieval.js' %}" type="text/javascript"></script>
<!-- Chartsjs --> <!-- Chartsjs -->
<script src="{% static 'catalog/js/Chart.min.js' %}" type="text/javascript"></script> <script src="{% static 'catalog/js/Chart.min.js' %}" type="text/javascript"></script>
<!-- Fengyuan Chen's Datepicker --> <!-- Fengyuan Chen's Datepicker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.js" <script src="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.js"
integrity="sha256-/7FLTdzP6CfC1VBAj/rsp3Rinuuu9leMRGd354hvk0k=" crossorigin="anonymous"></script> integrity="sha256-/7FLTdzP6CfC1VBAj/rsp3Rinuuu9leMRGd354hvk0k=" crossorigin="anonymous"></script>
<script src="{% static 'catalog/adminlte/bower_components/guides-master/dist/guides.min.js' %}" <script src="{% static 'catalog/adminlte/bower_components/guides-master/dist/guides.min.js' %}"
type="text/javascript"></script> type="text/javascript"></script>
{% block footer %}{% endblock %} {% block footer %}{% endblock %}
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
{% if messages %} {% if messages %}
<div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute"> <div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute">
{% for message in messages %} {% for message in messages %}
<div {% if message.tags %} class="fade in alert alert-dismissible alert-{{ message.tags }}"{% endif %}> <div {% if message.tags %} class="fade in alert alert-dismissible alert-{{ message.tags }}"{% endif %}>
...@@ -266,10 +279,10 @@ ...@@ -266,10 +279,10 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
{% block guide %} {% block guide %}
{% endblock %} {% endblock %}
</body> </body>
</html> </html>
......
MAPBOX_ACCESS_TOKEN = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw'; MAPBOX_ACCESS_TOKEN = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';
MAX_OPACITY = 1; MAX_OPACITY = 1;
FIRST_IMAGE_LAYER_INDEX = 2; FIRST_IMAGE_LAYER_INDEX = 2;
document.getElementById("light").checked = true;
// create wkt polygon // create wkt polygon
const wktFormat = new ol.format.WKT(); const wktFormat = new ol.format.WKT();
...@@ -79,6 +79,8 @@ else { ...@@ -79,6 +79,8 @@ else {
x = 'light'; x = 'light';
//console.log({x}) //console.log({x})
} }
document.getElementById(x).checked = true;
const polygonLayer = new ol.layer.Vector({ const polygonLayer = new ol.layer.Vector({
name: 'polygon', name: 'polygon',
source: new ol.source.Vector({ source: new ol.source.Vector({
...@@ -207,7 +209,7 @@ function changeLayers(especific_layerName) { ...@@ -207,7 +209,7 @@ function changeLayers(especific_layerName) {
} }
layers.set(layerName, xyz); layers.set(layerName, xyz);
sessionStorage.setItem(layerName, layerName); // replace sessionStorage.setItem(layerName, layerName);
}); });
} }
...@@ -223,7 +225,7 @@ function removeLayer(layerName) { ...@@ -223,7 +225,7 @@ function removeLayer(layerName) {
map.removeLayer(layers.get(layerName)); map.removeLayer(layers.get(layerName));
layers.delete(layerName); layers.delete(layerName);
sessionStorage.layers = layers; sessionStorage.removeItem(layerName)
} }
// set opacity to layers // set opacity to layers
......
...@@ -208,7 +208,7 @@ def Reports(request): ...@@ -208,7 +208,7 @@ def Reports(request):
for file in os.listdir(zip_path): for file in os.listdir(zip_path):
if file.endswith(".zip"): if file.endswith(".zip"):
zip = zip_path + "/" + file zip = zip_path + "/" + file
if os.path.exists(USERS_PATH + producto['user__email'] + '/' + str(producto['id']) + '/scl_data.json'):
if os.path.getsize(USERS_PATH + producto['user__email'] + "/" + str(producto['id']) + "/scl_data.json") > 3: if os.path.getsize(USERS_PATH + producto['user__email'] + "/" + str(producto['id']) + "/scl_data.json") > 3:
Data = True Data = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment