descripcion reportes

parent c6a9dc1f
......@@ -58,6 +58,7 @@ class Process(models.Model):
class Search(models.Model):
area = models.TextField(null=True)
search_name = models.TextField(default="Drawn polygon ")
description = models.TextField(default="")
user = models.ForeignKey(User, on_delete=models.CASCADE)
aggreg_date = models.DateTimeField(auto_now=True) # date of product aggregation
startDate = models.DateTimeField(verbose_name='Start Date')
......@@ -71,7 +72,7 @@ class Purchase(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
search = models.ForeignKey(Search, on_delete=models.CASCADE)
productList = models.TextField(verbose_name="JSON Product List")
name = models.TextField(default="Drawn polygon ")
name = models.TextField(default="")
description = models.TextField(default="")
purchased = models.BooleanField(default=False)
price = models.FloatField(default=0.0)
......
......@@ -156,6 +156,8 @@ function drawPolygon(element) {
// set input box with polygon city name
var input_text = polygon.city + ", " + polygon.state;
$("#ajax-input").val(input_text);
$('#search_name').val(input_text);
$("#area_description").val(polygon.description)
// remove prev polygon
osmap.removePolygon();
......@@ -308,8 +310,7 @@ $('#ajax-input').focus(function () {
$('#polygon-list').click(function () {
$('#option-list').hide();
OPT_LIST_IS_HIDDEN = true;
$('#search_name').val($('#ajax-input').val());
// $('#ajax-input').value = $(this);
//$('#area_description').val("hola");
});
......@@ -403,6 +404,11 @@ $(document).ready(function () {
// function for making POST request to productList in view.py
$('#product-form').submit(function (event) {
if ($('#ajax-input').val().length <= 0)
{
$('#search_name').val("Drawn Polygon");
$('#area_description').val("");
}
event.preventDefault();
erase_product_list_globe();
var submit_data = $('#product-form').serialize();
......
......@@ -141,6 +141,7 @@
{% csrf_token %}
<input type="hidden" id="user_name" name="user_name" value={{user.get_username}}>
<input type="hidden" id="search_name" name="search_name" value="Drawn Polygon">
<input type="hidden" id="area_description" name="area_description" value="">
<ul class="sidebar-menu" data-widget="tree">
<li class="treeview">
<a href="#">
......
......@@ -89,6 +89,8 @@ def productList(request):
end_date = req['end'][0][:10]
clouds = req['cloudPercentage'][0]
search_name = req['search_name'][0]
description = req['area_description'][0]
print(search_name)
cloud_percentage = "[0 TO " + req['cloudPercentage'][0] + "]"
......@@ -149,6 +151,8 @@ def productList(request):
clouds=clouds,
area=area,
search_name = search_name,
description = description,
)
listSearch.save()
......@@ -502,7 +506,7 @@ def Pay(request):
user = User.objects.get(id=request.user.id)
product_list = []
product_list = Purchase.objects.values('id', 'search__area', 'user', 'user__username', 'user__email', 'search_id',
'search__clouds', 'search__startDate', 'search__endDate').filter(user=user,
'search__clouds', 'search__startDate', 'search__endDate','search__search_name','search__description').filter(user=user,
purchased=0)
for product in product_list:
......@@ -565,7 +569,7 @@ def Pay(request):
# ~ data = {}
# ~ for products in product_list:
# ~ print(products)
# ~ print(products)
# ~ product = json.loads(products['productList'])
# ~ prod_list.append({
# ~ 'purchased': products['purchased'],
......@@ -577,7 +581,7 @@ def Pay(request):
# -------------------------------------
Purchase.objects.filter(user_id=request.user.id, purchased=0).update(purchased=True)
Purchase.objects.filter(user_id=request.user.id, purchased=0,pk=product['id']).update(purchased=True, description =product['search__description'], name=product['search__search_name'])
return redirect('../../reports')
......
$(document).ready(function () {
$('[data-toggle="popover"]').popover();
});
function showEditModal(zone, description, id) {
$('#edit_id').empty();
$('#zone').empty();
$('#description').empty();
$('#zone').val(zone);
$('#description').val(description);
$('#edit_id').val(id);
//$('#myModalTitle').append(name);
$("#editmodal").modal();
}
function openmodal(info) {
info2 = info.split(";");
$("#myModal").modal();
......@@ -142,6 +158,18 @@ function change_public(data) {
}
function SaveButton() {
$.ajax({
dataType: "json",
url: '../reports/ws/wsEditTitle',
data: {'purchase_id': $('#edit_id').val(),'zone': $('#zone').val(), 'description': $('#description').val()},
success: function (data) {
console.log(data)
}
});
}
function is_public(purchase_id, status) {
//alert(purchase_id);
$.ajax({
......@@ -149,23 +177,8 @@ function is_public(purchase_id, status) {
url: '../reports/ws/is_public',
data: {'purchase_id': purchase_id, 'status': status},
success: function (data) {
alert("cambiado");
alert(data);
}
});
};
function showEditModal(zone, description, id) {
$('#edit_id').empty();
$('#zone').empty();
$('#description').empty();
$('#zone').val(zone);
$('#description').val(description);
$('#edit_id').val(id);
//$('#myModalTitle').append(name);
$("#editmodal").modal();
}
$(document).ready(function () {
$('[data-toggle="popover"]').popover();
});
\ No newline at end of file
......@@ -168,11 +168,11 @@
{% for product in productList %}
<tr>
<td>
<a href="#" data-toggle="popover" data-trigger="hover"
data-content="{{ product.search_name }}"
<a href="#" id="title{{ product.purchase_id }}" data-toggle="popover" data-trigger="hover"
data-content="{% if product.description %}{{ product.description }}{% else %}Without Description{% endif %}"
onclick="showMyModalSetTitle('{{ product.search_name }}','{{ product.polygon }}');"> {{ product.search_name }}</a>
<a href="#" onclick="showEditModal('{{ product.search_name }}','Descripcion ekiz','{{ product.purchase_id }}')"><span
<a href="#" onclick="showEditModal('{{ product.search_name }}','{{ product.description }}','{{ product.purchase_id }}')"><span
class="fas fa-pencil-alt"
style="margin:3px 0 0 0"></span></a>
</td>
......@@ -299,10 +299,6 @@
<input type="text" class="form-group-lg" id="edit_id" name="edit_id">
<label>Description:</label>
<br>
<div class="form-group">
<label for="usr">Zone:</label>
<input type="text" class="form-control" id="zone" name="zone" style="text-align:center;">
......@@ -310,7 +306,7 @@
<div class="form-group">
<label for="pwd">Description:</label>
<textarea class="form-control" id="description" name="description"
<textarea rows="4" class="form-control" id="description" name="description"
style="text-align:center; resize: none"></textarea>
</div>
......@@ -318,7 +314,7 @@
<div class="modal-footer">
<input class="btn btn-primary pull-left " id="phSearchButton" type="submit" value="Save"/>
<a class="btn btn-primary pull-left " id="SaveButton" onclick="SaveButton()">Save</a>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</form>
</div>
......@@ -328,9 +324,6 @@
<!-- /.modals -->
{% endblock %}
{% block modals %}
{% endblock %}
......
......@@ -101,7 +101,7 @@ def Reports(request):
zip = ""
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate',
'search__endDate', 'search__process_id__name', 'search__search_name',
'is_public').filter(
'is_public','name','description').filter(
user_id=request.user.id, purchased=1)
for producto in product_list:
log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log"
......@@ -170,7 +170,8 @@ def Reports(request):
if file.endswith(".zip"):
zip = zip_path + "/" + file
productList.append({
"search_name": producto['search__search_name'],
"search_name": producto['name'],
"description": producto['description'],
"process": producto['search__process_id__name'],
"purchase_date": producto['aggreg_date'],
"startDate": producto['search__startDate'],
......@@ -482,7 +483,7 @@ def PDFGenerator(request, ruta, reporteDir, datasets):
maxi = 0
# for data in datasets:
for data in datasets[:len(datasets) - 1]:
if maxi > data['data'][index]:
if maxi > data['data'][index]:
maxi = maxi
else:
maxi = data['data'][index]
......@@ -576,15 +577,23 @@ def ProcessChartData(path):
# ---------------------------------------------------------------------------------
def wsIs_Public(request):
if request.is_ajax():
status = request.GET.get("status")
path = "/reports/" + request.GET.get("purchase_id") + "/scl_data"
purchase = Purchase.objects.get(pk=request.GET.get("purchase_id"))
purchase.is_public = request.GET.get("status")
purchase.save()
# print (purchase.aggreg_date)
return HttpResponse("hola")
else:
raise Http404
# ---------------------------------------------------------------------------------
def wsEditTitle(request):
if request.is_ajax():
purchase = Purchase.objects.get(pk=request.GET.get("purchase_id"))
purchase.name = request.GET.get("zone")
purchase.description = request.GET.get("description")
purchase.save()
print ("hola")
return HttpResponse("hola")
else:
raise Http404
\ No newline at end of file
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