# SVN changeset patch # User jsalyrosas # Date 2013-05-15 19:04:10.938748 # Revision 168 - Agregada la funcion que permite enviar un archivo a la API cliente de ABS CONTROL. Index: trunk/webapp/abs_webapp_dev/settings.py =================================================================== diff --git a/trunk/webapp/abs_webapp_dev/settings.py b/trunk/webapp/abs_webapp_dev/settings.py --- a/trunk/webapp/abs_webapp_dev/settings.py (revision 167) +++ b/trunk/webapp/abs_webapp_dev/settings.py (revision 168) @@ -1,7 +1,9 @@ # Django settings for abs_webapp_dev project. -import os +import os, sys PROJECT_DIR = os.path.split(os.path.dirname(__file__))[0] +API_DIR = "/home/dev/workspace/absclient" +sys.path.append(API_DIR) DEBUG = True TEMPLATE_DEBUG = DEBUG Index: trunk/webapp/abscontrol/urls.py =================================================================== diff --git a/trunk/webapp/abscontrol/urls.py b/trunk/webapp/abscontrol/urls.py --- a/trunk/webapp/abscontrol/urls.py (revision 167) +++ b/trunk/webapp/abscontrol/urls.py (revision 168) @@ -19,4 +19,5 @@ url(r'^saveImport/$', 'saveImport'), url(r'^(?P\d+)/(?P\d+)/overjro/(?P\d+)/$', 'overJRO'), url(r'^export/(?P\d+)/$', 'export'), + url(r'^send/(?P\d+)/$', 'send'), ) \ No newline at end of file Index: trunk/webapp/abscontrol/views.py =================================================================== diff --git a/trunk/webapp/abscontrol/views.py b/trunk/webapp/abscontrol/views.py --- a/trunk/webapp/abscontrol/views.py (revision 167) +++ b/trunk/webapp/abscontrol/views.py (revision 168) @@ -7,7 +7,7 @@ from abscontrol.models import Profile, Pattern, AntennaDown, AntennaUp from util.readABSFile import readABSFile from util.saveABSFile import saveABSFile - +from scripts.sendFile import sendFile txtAntenna = "[[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]," \ "[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]," \ @@ -342,3 +342,33 @@ response['X-Sendfile'] = '%s' % smart_str(filename) return response + +def send(request, profile_id): + listPatterns = [] + objProfile = Profile.objects.get(pk=profile_id) + exp_name = objProfile.name + + lsPatterns = objProfile.pattern_set.all() + for element in lsPatterns: + objAntennaUp = element.antennaup_set.get() + objAntennaDown = element.antennadown_set.get() + dicPatterns = {"number" : element.value, "up" : objAntennaUp.value, "down" : objAntennaDown.value} + listPatterns.append(dicPatterns) + + absFile = saveABSFile() + absFile.setParameters(settings.MEDIA_ROOT, exp_name, listPatterns) + filename, filesize = absFile.save() + + apiclient = sendFile() + apiclient.execute(filename) + + objProfile.hits += 1 + objProfile.save() + + message = "File sent successfully." + + profile_list = Profile.objects.all() + + return render_to_response('abscontrol/sendFile.html', {'message': message, "profile_list" : profile_list, + 'objProfile': objProfile, + }) Index: trunk/webapp/static/js/patterns.js =================================================================== diff --git a/trunk/webapp/static/js/patterns.js b/trunk/webapp/static/js/patterns.js --- a/trunk/webapp/static/js/patterns.js (revision 167) +++ b/trunk/webapp/static/js/patterns.js (revision 168) @@ -9,22 +9,22 @@ location.href="/abscontrol/view/" + $(this).val(); } }); - $('#lnkSave').click(function() { $('#frmPattern').submit(); }); - $('#lnkCancel').click(function() { if ($("#pattern_id").val() == 0){ location.href="/abscontrol/edit/" + $("#profile_id").val(); }else{ location.href="/abscontrol/" + $("#profile_id").val() + "/view/" + $("#pattern_id").val() } - }); - $('#lnkExport').click(function(){ profile_id = $(this).attr("alt"); location.href="/abscontrol/export/" + profile_id + "/"; }); + $('#lnkSendFile').click(function(){ + profile_id = $(this).attr("alt"); + location.href="/abscontrol/send/" + profile_id + "/"; + }); }); \ No newline at end of file Index: trunk/webapp/static/js/profiles.js =================================================================== diff --git a/trunk/webapp/static/js/profiles.js b/trunk/webapp/static/js/profiles.js --- a/trunk/webapp/static/js/profiles.js (revision 167) +++ b/trunk/webapp/static/js/profiles.js (revision 168) @@ -24,4 +24,8 @@ profile_id = $(this).attr("alt"); location.href="/abscontrol/export/" + profile_id + "/"; }); + $('#lnkSendFile').click(function(){ + profile_id = $(this).attr("alt"); + location.href="/abscontrol/send/" + profile_id + "/"; + }); }); \ No newline at end of file Index: trunk/webapp/templates/abscontrol/index.html =================================================================== diff --git a/trunk/webapp/templates/abscontrol/index.html b/trunk/webapp/templates/abscontrol/index.html --- a/trunk/webapp/templates/abscontrol/index.html (revision 167) +++ b/trunk/webapp/templates/abscontrol/index.html (revision 168) @@ -45,7 +45,7 @@
  • Import
  • {% if objProfile %}
  • Export
  • -
  • Apply
  • +
  • Send
  • {% endif %} Index: trunk/webapp/templates/abscontrol/sendFile.html =================================================================== diff --git a/trunk/webapp/templates/abscontrol/sendFile.html b/trunk/webapp/templates/abscontrol/sendFile.html new file mode 10644 --- /dev/null (revision 0) +++ b/trunk/webapp/templates/abscontrol/sendFile.html (revision 168) @@ -0,0 +1,10 @@ +{% extends "abscontrol/index.html" %} +{% block title %}ABS CONTROL:::::SENDING FILE{% endblock %} + +{% block maincolumn %} +
    +
    + +
    +
    +{% endblock %} \ No newline at end of file