diff --git a/mainapp/urls.py b/mainapp/urls.py
index 42247f077..dbdf42fcd 100644
--- a/mainapp/urls.py
+++ b/mainapp/urls.py
@@ -62,4 +62,5 @@
path('consent_success/', views.ConsentSuccess.as_view(), name='consent_success'),
url(r'c/(?P\d+)/(?P\d+)/$', views.VolunteerConsent.as_view(), name='volunteer_consent'),
url('missing_and_finding_persons/', views.ReportFindPerson.as_view(), name='report_find_person'),
+ url(r'renewvolunteer/(?P\d+)/$', views.RenewVolunteerPage.as_view(), name='renewvolunteer'),
]
diff --git a/mainapp/views.py b/mainapp/views.py
index 0b76491b0..74225715a 100644
--- a/mainapp/views.py
+++ b/mainapp/views.py
@@ -86,6 +86,45 @@ class RegisterVolunteer(CreateView):
fields = ['name', 'district', 'phone', 'organisation', 'area', 'address']
success_url = '/reg_success/'
+
+class RenewVolunteerForm(forms.ModelForm):
+
+
+ class Meta:
+ model = Volunteer
+ help_texts = {
+ 'local_body': 'Indicate the local body name',
+ 'date_time': 'Indicate the dates that you are available for volunteering',
+ }
+ fields = ['district', 'name', 'local_body', 'phone', 'email', 'date_time', 'has_consented']
+
+ read_only = ('phone',)
+ widgets = {
+ 'name': forms.Textarea(attrs={'rows':1}),
+ 'phone': forms.Textarea(attrs={'rows':3, 'readonly':True}),
+ }
+
+class RenewVolunteerPage(CreateView):
+ model = Volunteer
+ # form_class = RenewVolunteerForm
+ fields = ['district', 'name', 'local_body', 'phone', 'email', 'date_time', 'has_consented']
+ # read_only = ('phone',)
+ template_name = "mainapp/renew_volunteer.html"
+ success_url = '/reg_success/'
+ volunteer_ph = ""
+
+ def dispatch(self, request, *args, **kwargs):
+ self.volunteer_ph = kwargs['volunteer_ph']
+ return super().dispatch(request, *args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ # Call the base implementation first to get a context
+ context = super().get_context_data(**kwargs)
+ # data = get_object_or_404(self.model, pk=self.volunteer_ph)
+ context['current'] = get_object_or_404(self.model, pk=self.volunteer_ph)
+ return context
+
+
def volunteerdata(request):
filter = VolunteerFilter( request.GET, queryset=Volunteer.objects.all() )
req_data = filter.qs.order_by('-id')
diff --git a/renew_volunteer_sms.py b/renew_volunteer_sms.py
new file mode 100644
index 000000000..f2644d125
--- /dev/null
+++ b/renew_volunteer_sms.py
@@ -0,0 +1,68 @@
+# Dependencies - Requests, dateutil
+# Python 2.7.15
+
+# Expects a csv file's path containing volunteer details
+# Fill in the credentials in line 55, and run the script
+
+# Example usage:
+# python2 path/to/sms.py path/to/csvFile.csv
+
+import calendar
+import csv
+import datetime
+import sys
+import time
+
+import requests
+
+from dateutil import parser
+
+csvFile = sys.argv[1] #command line argument
+
+if __name__ == "__main__":
+
+ # csv file path not provided
+ if len(sys.argv) < 1:
+ sys.exit()
+
+ #stores failed sms
+ failed = open("Failed",'w')
+ fin = open(csvFile,'r')
+
+ # to avoid multiple sms to same mobile number
+ mark = {}
+
+ for fields in csv.reader(fin):
+
+ sendID = fields[0]
+ timestamp = fields[8]
+ mobile = fields[3]
+
+ if mobile in mark:
+ continue
+ mark[mobile]=1
+
+ if mobile.isdigit():
+ try:
+ # Converting timestamp to epoch
+ timestamp = parser.parse(timestamp)
+ timestamp = calendar.timegm(timestamp.utctimetuple())
+
+ # Preparing unique URL
+ url = 'http://keralarescue.in/c/' + sendID + "/" + str(timestamp)[-4:]
+ message = "If you would like to volunteer to do the damage assessment, please click this link " + url
+
+ payload = { 'username':'xxxxxxxx','password':'xxxxxxxx','message':message,'numbers':mobile}
+ response = requests.get('http://api.esms.kerala.gov.in/fastclient/SMSclient.php',params=payload)
+
+ except KeyboardInterrupt:
+
+ failed.write(mobile)
+ sys.exit()
+
+ except:
+
+ failed.write(mobile)
+
+ fin.close()
+ failed.close()
diff --git a/requirements.txt b/requirements.txt
index a5843f030..1bc511bf7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,3 +23,5 @@ django-storages==1.6.6
python-dateutil
beautifulsoup4==4.6.3
ddtrace==0.12.1
+pympler==0.5
+django_debug_toolbar==1.9.1
From 1c84c96a57237bf4c9e1a060171cd2c374db6d5c Mon Sep 17 00:00:00 2001
From: sudhin
Date: Mon, 27 Aug 2018 23:08:06 +0530
Subject: [PATCH 03/15] optimized code for sending verification sms to 80k
users
---
.gitignore | 1 +
floodrelief/settings.py | 13 +
.../management/commands/sendvolunteersms.py | 107 +++++
mainapp/management/commands/smsvolunteer.csv | 397 ++++++++++++++++++
mainapp/urls.py | 2 +
mainapp/views.py | 9 +
requirements.txt | 2 +
7 files changed, 531 insertions(+)
create mode 100644 mainapp/management/commands/sendvolunteersms.py
create mode 100644 mainapp/management/commands/smsvolunteer.csv
diff --git a/.gitignore b/.gitignore
index 24f54f6fa..105833ca1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ mysite.log
venv
.idea/*
media/
+logs/*
diff --git a/floodrelief/settings.py b/floodrelief/settings.py
index 4bb1d6582..c148f59dc 100644
--- a/floodrelief/settings.py
+++ b/floodrelief/settings.py
@@ -180,6 +180,9 @@ def get_list(text):
'simple': {
'format': '%(levelname)s %(message)s'
},
+ 'command': {
+ 'format': '%(asctime)s %(message)s'
+ },
},
'handlers': {
'file': {
@@ -188,6 +191,12 @@ def get_list(text):
'filename': 'mysite.log',
'formatter': 'verbose'
},
+ 'command': {
+ 'level': 'DEBUG',
+ 'class': 'logging.FileHandler',
+ 'filename': 'logs/command.log',
+ 'formatter': 'command'
+ },
},
'loggers': {
'django': {
@@ -199,6 +208,10 @@ def get_list(text):
'handlers': ['file'],
'level': 'DEBUG',
},
+ 'send_volunteer_sms': {
+ 'handlers': ['command'],
+ 'level': 'DEBUG',
+ },
}
}
diff --git a/mainapp/management/commands/sendvolunteersms.py b/mainapp/management/commands/sendvolunteersms.py
new file mode 100644
index 000000000..4fc87c878
--- /dev/null
+++ b/mainapp/management/commands/sendvolunteersms.py
@@ -0,0 +1,107 @@
+import os
+
+from django.core.management.base import BaseCommand
+from django.core.cache import cache
+import requests
+from threading import Thread
+from datetime import datetime
+
+from django.conf import settings
+import csv
+from dateutil import parser
+import time
+
+import logging
+import calendar
+
+
+logger = logging.getLogger('send_volunteer_sms')
+
+
+# python manage.py sendvolunteersms
+# python manage.py sendvolunteersms /tmp/volunteer.csv
+# python manage.py sendvolunteersms --clearcache=1
+class Command(BaseCommand):
+ # SMS_API_URL = "http://api.esms.kerala.gov.in/fastclient/SMSclient.php"
+ SMS_API_URL = "http://127.0.0.1:8000/test_send_sms/"
+ API_USERNAME = os.environ.get("SMS_USER")
+ API_PASSWORD = os.environ.get("SMS_PASSWORD")
+
+ DEFAULT_CSV = os.path.join(settings.BASE_DIR,
+ 'mainapp/management/commands/smsvolunteer.csv')
+ BATCH_MAX = 10
+
+ msg_url_template = "http://keralarescue.in/c/{sendID}/{timestamp}"
+ message_template = "Thank you for registering to volunteer. Please click here to confirm {url}"
+ success_check_cache_key = "SendingFailed_{phone}"
+
+ def add_arguments(self, parser):
+ parser.add_argument('path', nargs='?', type=str)
+ parser.add_argument('--clearcache', nargs='?', type=bool)
+
+ @property
+ def volunteers(self):
+ with open(self.path, "r") as volunteers:
+ for volunteer in csv.DictReader(volunteers):
+ yield volunteer
+
+ @staticmethod
+ def clean_timestamp(timestamp):
+ # not clear about this logic just copied from -> sms.py
+ timestamp = parser.parse(timestamp)
+ timestamp = calendar.timegm(timestamp.utctimetuple())
+ return str(timestamp)[-4:]
+
+ def send_sms(self, payload):
+ res = requests.get(self.SMS_API_URL, params=payload)
+ if res.status_code in (200, 201):
+ cache.set(self.success_check_cache_key.format(
+ phone=payload["numbers"]), True)
+ else:
+ logger.info("failed {} {}".format())
+
+ def process_batch(self, batch):
+ tasks = []
+ for payload in batch:
+ self.total_count += 1
+ t = Thread(target=self.send_sms,
+ args=(payload,))
+ tasks.append(t)
+ t.start()
+
+ for task in tasks:
+ t.join()
+
+ def handle(self, *args, **options):
+ if options["clearcache"]:
+ logger.info("clearing cache for sendvolunteersms.")
+ cache.delete_pattern(self.success_check_cache_key.format(phone="*"))
+ else:
+ t1 = time.time()
+ self.path = options["path"] if options["path"] else self.DEFAULT_CSV
+ batch = []
+ batch_count = 0
+ self.total_count = 0
+ logger.info("STARTING sendvolunteersms.")
+
+ for volunteer in self.volunteers:
+ msg_url = self.msg_url_template.format(sendID=volunteer["ID"],
+ timestamp="{:%Y-%m-%d %H:%M}".format(datetime.now()))
+ message = self.message_template.format(url=msg_url)
+ payload = {'username': self.API_USERNAME,
+ 'password': self.API_PASSWORD,
+ 'message': message,
+ 'numbers': volunteer["phone"]}
+ if not cache.get(
+ self.success_check_cache_key.format(
+ phone=payload["numbers"])):
+ batch.append(payload)
+ batch_count += 1
+ if batch_count == self.BATCH_MAX:
+ self.process_batch(payload)
+ batch_count = 0
+ batch = []
+ if batch:
+ self.process_batch(batch)
+ logger.info("{} COMPLETED IN {} Seconds sendvolunteersms.".format(self.total_count,
+ time.time() - t1))
diff --git a/mainapp/management/commands/smsvolunteer.csv b/mainapp/management/commands/smsvolunteer.csv
new file mode 100644
index 000000000..1d81eeaa2
--- /dev/null
+++ b/mainapp/management/commands/smsvolunteer.csv
@@ -0,0 +1,397 @@
+ID,phone
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+
+ID,phone
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+ID,phone
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+ID,phone
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
+3,0612345678
+1,0123456789
+2,9876543210
diff --git a/mainapp/urls.py b/mainapp/urls.py
index 42247f077..f60801e57 100644
--- a/mainapp/urls.py
+++ b/mainapp/urls.py
@@ -62,4 +62,6 @@
path('consent_success/', views.ConsentSuccess.as_view(), name='consent_success'),
url(r'c/(?P\d+)/(?P\d+)/$', views.VolunteerConsent.as_view(), name='volunteer_consent'),
url('missing_and_finding_persons/', views.ReportFindPerson.as_view(), name='report_find_person'),
+ url('test_send_sms/', views.test_send_sms, name='test_send_sms'),
+
]
diff --git a/mainapp/views.py b/mainapp/views.py
index 0b76491b0..99fe8c1d3 100644
--- a/mainapp/views.py
+++ b/mainapp/views.py
@@ -941,3 +941,12 @@ class CollectionCenterView(CreateView):
model = CollectionCenter
form_class = CollectionCenterForm
success_url = '/collection_centers/'
+
+
+def test_send_sms(request):
+ print(request.GET)
+ import time
+ time.sleep(2)
+ return JsonResponse({
+ "success": True
+ }, safe=False)
diff --git a/requirements.txt b/requirements.txt
index a5843f030..569b5e3f4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,3 +23,5 @@ django-storages==1.6.6
python-dateutil
beautifulsoup4==4.6.3
ddtrace==0.12.1
+Pympler==0.51
+django-debug-toolbar==1.9.11
From 3b0cfb7a33d00d185fa60f2034f53758c8534ee4 Mon Sep 17 00:00:00 2001
From: sudhin
Date: Tue, 28 Aug 2018 00:42:29 +0530
Subject: [PATCH 04/15] code cleanup
---
floodrelief/settings.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/floodrelief/settings.py b/floodrelief/settings.py
index c148f59dc..08a5045b7 100644
--- a/floodrelief/settings.py
+++ b/floodrelief/settings.py
@@ -191,10 +191,10 @@ def get_list(text):
'filename': 'mysite.log',
'formatter': 'verbose'
},
- 'command': {
+ 'send_volunteer_sms': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
- 'filename': 'logs/command.log',
+ 'filename': 'logs/send_volunteer_sms.log',
'formatter': 'command'
},
},
@@ -209,7 +209,7 @@ def get_list(text):
'level': 'DEBUG',
},
'send_volunteer_sms': {
- 'handlers': ['command'],
+ 'handlers': ['send_volunteer_sms'],
'level': 'DEBUG',
},
}
From 502df77116d6a4e64ae37c89c401c6c698d9b131 Mon Sep 17 00:00:00 2001
From: sudhin
Date: Tue, 28 Aug 2018 00:42:50 +0530
Subject: [PATCH 05/15] sample csv
---
mainapp/management/commands/smsvolunteer.csv | 227 -------------------
1 file changed, 227 deletions(-)
diff --git a/mainapp/management/commands/smsvolunteer.csv b/mainapp/management/commands/smsvolunteer.csv
index 1d81eeaa2..b2898b9db 100644
--- a/mainapp/management/commands/smsvolunteer.csv
+++ b/mainapp/management/commands/smsvolunteer.csv
@@ -93,120 +93,6 @@ ID,phone
2,9876543210
3,0612345678
1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-
-ID,phone
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-ID,phone
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
1,0123456789
2,9876543210
3,0612345678
@@ -282,116 +168,3 @@ ID,phone
1,0123456789
2,9876543210
3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-ID,phone
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
-3,0612345678
-1,0123456789
-2,9876543210
From 7d3eaba81037cf19a6bc76db10c14a07f50bad2a Mon Sep 17 00:00:00 2001
From: sudhin
Date: Tue, 28 Aug 2018 09:36:22 +0530
Subject: [PATCH 06/15] requirements updated
---
requirements.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 569b5e3f4..1bc511bf7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -23,5 +23,5 @@ django-storages==1.6.6
python-dateutil
beautifulsoup4==4.6.3
ddtrace==0.12.1
-Pympler==0.51
-django-debug-toolbar==1.9.11
+pympler==0.5
+django_debug_toolbar==1.9.1
From 7a00a610a22dc7cb522903d207a1f62534ef3a0e Mon Sep 17 00:00:00 2001
From: Jino Jossy
Date: Tue, 28 Aug 2018 13:01:37 +0530
Subject: [PATCH 07/15] added new view and url for fail scenario
---
mainapp/migrations/0093_auto_20180827_1657.py | 4 -
mainapp/migrations/0095_auto_20180828_1140.py | 19 ++
mainapp/migrations/0096_auto_20180828_1147.py | 18 ++
mainapp/models.py | 6 +-
mainapp/templates/mainapp/reg_fail.html | 9 +
.../templates/mainapp/renew_volunteer.html | 243 ++++++++++--------
mainapp/urls.py | 1 +
mainapp/views.py | 13 +-
8 files changed, 188 insertions(+), 125 deletions(-)
create mode 100644 mainapp/migrations/0095_auto_20180828_1140.py
create mode 100644 mainapp/migrations/0096_auto_20180828_1147.py
create mode 100644 mainapp/templates/mainapp/reg_fail.html
diff --git a/mainapp/migrations/0093_auto_20180827_1657.py b/mainapp/migrations/0093_auto_20180827_1657.py
index df5ddb12c..7b161455b 100644
--- a/mainapp/migrations/0093_auto_20180827_1657.py
+++ b/mainapp/migrations/0093_auto_20180827_1657.py
@@ -11,10 +11,6 @@ class Migration(migrations.Migration):
]
operations = [
- migrations.RemoveField(
- model_name='volunteer',
- name='id',
- ),
migrations.AlterField(
model_name='volunteer',
name='phone',
diff --git a/mainapp/migrations/0095_auto_20180828_1140.py b/mainapp/migrations/0095_auto_20180828_1140.py
new file mode 100644
index 000000000..3fb28ebe0
--- /dev/null
+++ b/mainapp/migrations/0095_auto_20180828_1140.py
@@ -0,0 +1,19 @@
+# Generated by Django 2.1 on 2018-08-28 06:10
+
+import django.core.validators
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('mainapp', '0094_volunteer_email'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='volunteer',
+ name='phone',
+ field=models.CharField(max_length=14, validators=[django.core.validators.RegexValidator(code='invalid_mobile', message='Please Enter 10 digit mobile number or landline as 0', regex='^((\\+91|91|0)[\\- ]{0,1})?[456789]\\d{9}$')], verbose_name='Phone - ഫോണ്\u200d നമ്പര്\u200d'),
+ ),
+ ]
diff --git a/mainapp/migrations/0096_auto_20180828_1147.py b/mainapp/migrations/0096_auto_20180828_1147.py
new file mode 100644
index 000000000..1d0d41567
--- /dev/null
+++ b/mainapp/migrations/0096_auto_20180828_1147.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.1 on 2018-08-28 06:17
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('mainapp', '0095_auto_20180828_1140'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='volunteer',
+ name='local_body',
+ field=models.TextField(default='', max_length=250),
+ ),
+ ]
diff --git a/mainapp/models.py b/mainapp/models.py
index 3d9b2d031..1778e557c 100644
--- a/mainapp/models.py
+++ b/mainapp/models.py
@@ -2,7 +2,6 @@
import uuid
from enum import Enum
import csv
-from datetime import datetime
import codecs
from django.db import models
@@ -196,12 +195,11 @@ class Volunteer(models.Model):
verbose_name="District - ജില്ല"
)
name = models.CharField(max_length=100, verbose_name="Name - പേര്")
-
phone_number_regex = RegexValidator(regex='^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$', message='Please Enter 10 digit mobile number or landline as 0', code='invalid_mobile')
- phone = models.CharField(max_length=14, verbose_name="Phone - ഫോണ് നമ്പര്", validators=[phone_number_regex], primary_key=True)
+ phone = models.CharField(max_length=14, verbose_name="Phone - ഫോണ് നമ്പര്", validators=[phone_number_regex])
email = models.EmailField(max_length=250, blank=True)
organisation = models.CharField(max_length=250, verbose_name="Organization (സംഘടന) / Institution")
- local_body = models.CharField(max_length=250, default= "")
+ local_body = models.TextField(max_length=250, default= "")
address = models.TextField(verbose_name="Address - വിലാസം")
area = models.CharField(
max_length = 15,
diff --git a/mainapp/templates/mainapp/reg_fail.html b/mainapp/templates/mainapp/reg_fail.html
new file mode 100644
index 000000000..b1a3a7be4
--- /dev/null
+++ b/mainapp/templates/mainapp/reg_fail.html
@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+{% load bootstrap3 %}
+
+{% block content %}
+
+Your request has been failed
+താങ്കളുടെ അഭ്യർത്ഥന പരാജയപ്പെട്ടു
+
+{% endblock %}
diff --git a/mainapp/templates/mainapp/renew_volunteer.html b/mainapp/templates/mainapp/renew_volunteer.html
index 6a0ab0dd3..42471c4a3 100644
--- a/mainapp/templates/mainapp/renew_volunteer.html
+++ b/mainapp/templates/mainapp/renew_volunteer.html
@@ -13,119 +13,138 @@
Renew as Volunteer
വൊളന്റീയര് പുതുക്കാൻ
- |