From 75fac8bcfc649c86ab6911c9b20e80e4605c40f6 Mon Sep 17 00:00:00 2001 From: Shiv K Sah Date: Fri, 14 Jul 2017 21:36:31 +0530 Subject: [PATCH 1/3] SMS Broadcast - send bulk sms to network (current user select network) - send bulk sms to tower (user can select any BTS) - send sms to IMIS, sms can be send to multiple IMSI at same time. --- .../static/js/dashboard/sms-broadcast.js | 98 ++++++++++++++++ .../network_detail/denomination.html | 1 + .../dashboard/network_detail/edit.html | 1 + .../network_detail/inactive-subscribers.html | 1 + .../dashboard/network_detail/info.html | 4 + .../dashboard/network_detail/nav.html | 5 + .../dashboard/subscriber_detail/activity.html | 1 + .../subscriber_detail/adjust_credit.html | 3 +- .../subscriber_detail/broadcast.html | 71 ++++++++++++ .../dashboard/subscriber_detail/edit.html | 1 + .../dashboard/subscriber_detail/info.html | 4 + .../dashboard/subscriber_detail/nav.html | 9 +- .../dashboard/tower_detail/deregister.html | 3 +- .../dashboard/tower_detail/edit.html | 1 + .../dashboard/tower_detail/info.html | 1 + .../dashboard/tower_detail/monitor.html | 1 + .../templates/dashboard/tower_detail/nav.html | 5 + .../dashboard/tower_detail/tower_events.html | 4 + .../dashboard/tower_detail/tower_select.html | 12 ++ cloud/endagaweb/templatetags/apptags.py | 15 ++- .../endagaweb/tests/test_subscriber_views.py | 26 +++++ cloud/endagaweb/urls.py | 3 + cloud/endagaweb/views/dashboard.py | 106 +++++++++++++++++- cloud/endagaweb/views/towers.py | 5 + 24 files changed, 368 insertions(+), 13 deletions(-) create mode 100644 cloud/endagaweb/static/js/dashboard/sms-broadcast.js create mode 100644 cloud/endagaweb/templates/dashboard/subscriber_detail/broadcast.html create mode 100644 cloud/endagaweb/templates/dashboard/tower_detail/tower_select.html diff --git a/cloud/endagaweb/static/js/dashboard/sms-broadcast.js b/cloud/endagaweb/static/js/dashboard/sms-broadcast.js new file mode 100644 index 00000000..b58e21dd --- /dev/null +++ b/cloud/endagaweb/static/js/dashboard/sms-broadcast.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + function broadcastSms() { + var data = { + sendto: $('input[type=radio][name="send_to"]:checked').val(), + network_id: $('#network_id').val(), + tower_id: $('#bts_id').val(), + imsi: $('#imsi').val(), + message: $('#message').val(), + csrfmiddlewaretoken: $('#token').val(), + }; + $.post('/dashboard/broadcast', data, function(response) { + if (response['status'] == 'ok') { + // Show that it was successful and then reload the page. + // Clear out any old messages and show the div again. + $('#messages-container').html(); + $('#messages-container').css('opacity', 1); + var html = ''; + response['messages'].map(function(message) { + html += '
' + message + '
'; + }); + $('#messages-container').html(html).show(); + setTimeout(function() { + location.reload(); + }, 800); + } else { + // Show the messages that were sent back. + // Clear out any old messages and show the div again. + $('#messages-container').html(); + $('#messages-container').css('opacity', 1); + var html = ''; + response['messages'].map(function(message) { + html += '
' + message + '
'; + }); + $('#messages-container').html(html).show(); + setTimeout(function() { + $('#messages-container').fadeTo(500, 0); + $('#messages-container').hide(); + }, 4000); + } + }); + return false; + } + +$(document).ready(function() { + + $('input[type=radio][name="send_to"]').change(function() { + if (this.value == 'network') { + $('#network_row').show(); + $('#tower_row').hide(); + $('#imsi_row').hide(); + } else if (this.value == 'tower') { + $('#network_row').hide(); + $('#tower_row').show(); + $('#imsi_row').hide(); + } else if (this.value == 'imsi') { + $('#network_row').hide(); + $('#tower_row').hide(); + $('#imsi_row').show(); + } else { + $('#network_row').hide(); + $('#tower_row').hide(); + $('#imsi_row').show(); + } + }); + $('#broadcast-modal').on('shown.bs.modal', function() { + $('#broadcast-form')[0].reset(); + $('#network_row').hide(); + $('#tower_row').hide(); + $('#imsi_row').show(); + if($('input[type=radio][name="send_to"]:checked').val()) { + var selected = $('input[type=radio][name="send_to"]:checked').val(); + if (selected == 'network') { + $('#network_row').show(); + $('#tower_row').hide(); + $('#imsi_row').hide(); + } else if (selected == 'tower') { + $('#network_row').hide(); + $('#tower_row').show(); + $('#imsi_row').hide(); + } else if (selected == 'imsi') { + $('#network_row').hide(); + $('#tower_row').hide(); + $('#imsi_row').show(); + } else { + $('#network_row').hide(); + $('#tower_row').hide(); + $('#imsi_row').show(); + } + } + }); +}); diff --git a/cloud/endagaweb/templates/dashboard/network_detail/denomination.html b/cloud/endagaweb/templates/dashboard/network_detail/denomination.html index 3e7582f0..6fa07ac3 100644 --- a/cloud/endagaweb/templates/dashboard/network_detail/denomination.html +++ b/cloud/endagaweb/templates/dashboard/network_detail/denomination.html @@ -149,6 +149,7 @@

+ $(function() { // Show or hide parts of the form when autoupgrade is enabled or disabled. $('input:radio').change(function() { diff --git a/cloud/endagaweb/templates/dashboard/network_detail/inactive-subscribers.html b/cloud/endagaweb/templates/dashboard/network_detail/inactive-subscribers.html index eb786070..c299f916 100644 --- a/cloud/endagaweb/templates/dashboard/network_detail/inactive-subscribers.html +++ b/cloud/endagaweb/templates/dashboard/network_detail/inactive-subscribers.html @@ -150,5 +150,6 @@ }); }); + {% endblock %} diff --git a/cloud/endagaweb/templates/dashboard/network_detail/info.html b/cloud/endagaweb/templates/dashboard/network_detail/info.html index 6ae1b2c5..f877da3e 100644 --- a/cloud/endagaweb/templates/dashboard/network_detail/info.html +++ b/cloud/endagaweb/templates/dashboard/network_detail/info.html @@ -81,3 +81,7 @@ {% endblock %} + +{% block js %} + +{% endblock %} diff --git a/cloud/endagaweb/templates/dashboard/network_detail/nav.html b/cloud/endagaweb/templates/dashboard/network_detail/nav.html index d2c2d396..837351f6 100644 --- a/cloud/endagaweb/templates/dashboard/network_detail/nav.html +++ b/cloud/endagaweb/templates/dashboard/network_detail/nav.html @@ -43,5 +43,10 @@ {% else %}{% url 'network-edit' %} {% endif %}">Edit + +
  • + SMS Broadcast +
  • +{% include "dashboard/subscriber_detail/broadcast.html" with target='network' %} diff --git a/cloud/endagaweb/templates/dashboard/subscriber_detail/activity.html b/cloud/endagaweb/templates/dashboard/subscriber_detail/activity.html index 7c0c47db..1b28d204 100644 --- a/cloud/endagaweb/templates/dashboard/subscriber_detail/activity.html +++ b/cloud/endagaweb/templates/dashboard/subscriber_detail/activity.html @@ -121,4 +121,5 @@

    No events matched your search.

    + {% endblock %} diff --git a/cloud/endagaweb/templates/dashboard/subscriber_detail/adjust_credit.html b/cloud/endagaweb/templates/dashboard/subscriber_detail/adjust_credit.html index b2078ef7..0ca0f8d8 100644 --- a/cloud/endagaweb/templates/dashboard/subscriber_detail/adjust_credit.html +++ b/cloud/endagaweb/templates/dashboard/subscriber_detail/adjust_credit.html @@ -69,4 +69,5 @@ var adjust_credit_url = "{% url 'subscriber-adjust-credit' imsi=subscriber.imsi %}"; -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/cloud/endagaweb/templates/dashboard/subscriber_detail/broadcast.html b/cloud/endagaweb/templates/dashboard/subscriber_detail/broadcast.html new file mode 100644 index 00000000..fcee372c --- /dev/null +++ b/cloud/endagaweb/templates/dashboard/subscriber_detail/broadcast.html @@ -0,0 +1,71 @@ +{% load apptags %} + diff --git a/cloud/endagaweb/templates/dashboard/subscriber_detail/edit.html b/cloud/endagaweb/templates/dashboard/subscriber_detail/edit.html index 11946e86..2d2be911 100644 --- a/cloud/endagaweb/templates/dashboard/subscriber_detail/edit.html +++ b/cloud/endagaweb/templates/dashboard/subscriber_detail/edit.html @@ -131,6 +131,7 @@