Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renew as volunteer #3

Merged
28 changes: 28 additions & 0 deletions mainapp/migrations/0092_auto_20180828_1428.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.1 on 2018-08-28 08:58

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0091_merge_20180825_1236'),
]

operations = [
migrations.AddField(
model_name='volunteer',
name='date_time',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='volunteer',
name='email',
field=models.EmailField(blank=True, max_length=250),
),
migrations.AddField(
model_name='volunteer',
name='local_body',
field=models.TextField(default='', max_length=250),
),
]
24 changes: 22 additions & 2 deletions mainapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +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<std code><phone number>', code='invalid_mobile')
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.TextField(max_length=250, default= "")
address = models.TextField(verbose_name="Address - വിലാസം")
area = models.CharField(
max_length = 15,
Expand All @@ -208,6 +208,7 @@ class Volunteer(models.Model):
)
is_spoc = models.BooleanField(default=False, verbose_name="Is point of contact")
joined = models.DateTimeField(auto_now_add=True)
date_time = models.TextField(blank=True)
is_active = models.BooleanField(default=True)
has_consented = models.BooleanField(default=False, verbose_name="Available")

Expand All @@ -218,6 +219,25 @@ class Meta:
def __str__(self):
return self.name

@property
def district_name(self):
return {
'alp': 'Alappuzha - ആലപ്പുഴ',
'ekm': 'Ernakulam - എറണാകുളം',
'idk': 'Idukki - ഇടുക്കി',
'knr': 'Kannur - കണ്ണൂർ',
'ksr': 'Kasaragod - കാസർഗോഡ്',
'kol': 'Kollam - കൊല്ലം',
'ktm': 'Kottayam - കോട്ടയം',
'koz': 'Kozhikode - കോഴിക്കോട്',
'mpm': 'Malappuram - മലപ്പുറം',
'pkd': 'Palakkad - പാലക്കാട്',
'ptm': 'Pathanamthitta - പത്തനംതിട്ട',
'tvm': 'Thiruvananthapuram - തിരുവനന്തപുരം',
'tcr': 'Thrissur - തൃശ്ശൂർ',
'wnd': 'Wayanad - വയനാട്',
}.get(self.district, 'Unknown')


class NGO(models.Model):
district = models.CharField(
Expand Down
9 changes: 9 additions & 0 deletions mainapp/templates/mainapp/reg_fail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block content %}

<h3 align="center">Your request has been failed </h3>
<h3 align="center">താങ്കളുടെ അഭ്യർത്ഥന പരാജയപ്പെട്ടു </h3>

{% endblock %}
267 changes: 267 additions & 0 deletions mainapp/templates/mainapp/renew_volunteer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
{% extends 'base.html' %} {% load bootstrap3 %} {% block content %}
<!--Navigation Breadcrumbs-->
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li>
<li class="breadcrumb-item"><a href="../ngo-volunteer/">Renew as a Volunteer or NGO</a></li>
<li class="breadcrumb-item active" aria-current="page">Renew as Volunteer</li>
</ol>
</nav>
<h1 class="text-center">Renew as Volunteer</h1>
<h2 class="text-center">വൊളന്‍റീയര്‍ പുതുക്കാൻ</h2>
<form method="post" id="volunteer_consent_form" action="/renewvolunteer/{{ current.phone }}/">{% csrf_token %}
<fieldset>
<p id="head"></p>
<legend>Personal Details | വ്യക്തിഗത വിശദാംശങ്ങൾ</legend>
<div class="form-group">
<p id="p1"></p>
<label class="control-label" for="id_name">Name - പേര്</label>
<input type="text" name="name" maxlength="100" class="form-control" placeholder="Name - പേര്" title="" id="id_name" value="{{ current.name }}">
</div>
<div class="form-group">
<p id="p2"></p>
<label class="control-label" for="id_phone">Phone - ഫോണ്‍ നമ്പര്‍</label>
<input type="text" name="phone" maxlength="14" class="form-control" placeholder="Phone - ഫോണ്‍ നമ്പര്‍" value="{{ current.phone }}"
title="Not Editable" disabled id="id_phone">
</div>
<div class="form-group">
<p id="p3"></p>
<label class="control-label" for="id_phone">Email - ഇമെയിൽ</label>
<input type="text" name="email" maxlength="150" class="form-control" placeholder="Email - ഇമെയിൽ" title="" value="{{ current.email }}"
id="id_email" />
</div>
<div class="form-group ">
<p id="p4"></p>
<label class="control-label " for="id_address">Address - വിലാസം</label>
<textarea name="address" cols="40 " rows="10 " class="form-control " placeholder="Address - വിലാസം " title="" id="id_address">{{ current.address }}</textarea>
</div>
<div class="form-group">
<p id="p5"></p>
<label class="control-label" for="id_area">District - ജില്ല</label>
<select name="area" class="form-control" title="" id="id_area">
<!-- want to change the value attribute of option-->
<option value="" selected>---------</option>
<option value="mlp">Malappuram</option>
<option value="tvr">Thiruvananthapuram</option>
<option value="elw">Ernakulam</option>
<option value="mew">Thrissur</option>
<option value="cvw">Kozhikode</option>
<option value="plw">Palakkad</option>
<option value="vls">Kollam</option>
<option value="ckg">Kannur</option>
<option value="rlo">Alappuzha</option>
<option value="cln">Kottayam</option>
<option value="bot">Kasaragod</option>
<option value="rck">Pathanamthitta</option>
<option value="oth">Idukki</option>
<option value="oth">Wayanad</option>
</select>
</div>
<div class="form-group">
<p id="p6"></p>
<label class="control-label" for="id_local_body">Local Body Name - പ്രാദേശിക ബോഡി നാമം</label>
<select name="local_body" class="form-control" title="" id="id_local_body">
<option value="" selected>---------</option>
<!-- The Value Attribute Need To Removed.Name will be value -->
<option value="dcr">something</option>
<option value="dcr">something</option>
</select>
</div>
</fieldset>
<fieldset>
<p id="p7"></p>
<legend>Organisation/Institution Details (optional) | ഓർഗനൈസേഷൻ / സ്ഥാപനം വിശദാംശങ്ങൾ</legend>
<div class="form-group ">
<label class="control-label " for="id_organisation ">Organization (സംഘടന) / Institution </label>
<input type="text " name="organisation " maxlength="250 " class="form-control " placeholder="Organization (സംഘടന) /
Institution " title=" " id="id_organisation " value="{{ current.organisation }}">
</div>
</fieldset>
<fieldset>
<p id="p8"></p>
<legend>Available Date & Time To Work | ലഭ്യമായ തിയ്യതിയും ജോലി ചെയ്യാനുള്ള സമയവും</legend>
<div class="form-group">
<label class="control-label" for="id_available_date">Available Date - ലഭ്യമായ തിയ്യതി</label>
<input type="text" name="date" maxlength="150" class="form-control" placeholder="Available Date - ലഭ്യമായ തിയ്യതി" title=""
id="id_date">
</div>
<div class="form-group">
<p id="p9"></p>
<label class="control-label" for="id_time">Available Time - ലഭ്യമായ സമയം</label>
<input type="text" name="time" maxlength="150" class="form-control" placeholder="Available Time - ലഭ്യമായ സമയം" title=""
id="id_time">
</div>
</fieldset>
<fieldset>
<legend>Account Creation | അക്കൗണ്ട് സൃഷ്ടിക്കൽ</legend>
<div class="form-group">
<p id="p10"></p>
<label class="control-label" for="id_pass">Password - പാസ്വേഡ്</label>
<input type="password" name="password" maxlength="150" class="form-control" placeholder="Password - പാസ്വേഡ്" title="" id="id_password">
</div>
<div class="form-group">
<p id="p11"></p>
<label class="control-label" for="id_re_pass">Retype Password - പാസ്വേഡ് വീണ്ടും ടൈപ്പുചെയ്യുക </label>
<input type="password" name="re_password" maxlength="150" class="form-control" placeholder="Retype Password - പാസ്വേഡ് വീണ്ടും ടൈപ്പുചെയ്യുക"
title="" id="id_re_password">
</div>
</fieldset>
<div class="form-group">
<input type="hidden" name="is_active" value="{{ current.is_active }}" />
<label>
<input id="consent" type="radio" checked class="big-input" /> Like to Continue As A Volunteer <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ഒരു വോളന്റിയായി തുടരാൻ ആഗ്രഹിക്കുന്നു
</label>
<label>
<input id="not_consent" type="radio" class="big-input" /> Don't like to Continue As A Volunteer<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ഒരു വോളന്റിയായി തുടരാൻ ഇഷ്ടപ്പെടുന്നില്ല
</label>
</div>
<div class="form-group ">
<blockquote><small>
By providing your personal information, you consent to making such information accessible to persons who visit this website.
You further acknowledge and agree that in order to serve the specific purposes for which personal information
is volunteered by you, such information needs to be accessible to the public at large and therefore, by volunteering
your information on this website, you consent to making such information public. By providing your phone
number and email address, you further consent to being contacted by anyone who accesses such information
through this website. The creators of this website or the government of Kerala shall not be liable for any
unauthorized use, misuse or sharing of such information.
</small></blockquote>
<div class="form-group">
<p id="p12"></p>
<label><input id="register_consent" type="checkbox" value="" class="big-input"> I agree to the terms and conditions
| നിയമങ്ങളും വ്യവസ്തകളും ഞാന് അംഗീകരിക്കുന്നു</label>
</div>
<div class="form-group">
<button type="submit " class="btn btn-primary " id="submit_btn"><span class="glyphicon glyphicon-star "></span>
Submit</button>
</div>
</div>
</form>
<script src="./Kerala Rescue_files/jquery.min.js "></script>
<script>
$(document).ready(function () {
$("[name=other_status] ").attr('type', 'hidden');
$("[name=other_status] ").attr(' ', false)
$("[for=id_other_status] ").hide();
})
$("[name=status] ").change(function () {
var value = this.value;
if (value !== 'otr') {
$("[name=other_status] ").attr('type', 'hidden')
$("[name=other_status] ").attr(' ', false)
// $("[for=id_other_status] ").hide();
} else {
$("[name=other_status] ").attr('type', 'text')
// $("[for=id_other_status] ").show();
}
})
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});


var status;
$(document).ready(function () {
$('#submit_btn').click(function (e) {

var name = $('#id_name').val();
var phone = $('#id_phone').val();
var email = $('#id_email').val();
var addr = $('#id_address').val();
var area = $('#id_area').val();
var local_body = $('#id_local_body').val();
var org = $('#id_organization').val();
var date = $('#id_date').val();
var time = $('#id_time').val();
var pass = $('#id_password').val();
var re_pass = $('#id_re_password').val();

var name_regex = /^[a-zA-Z]+$/;
var email_regex = /^([0-9a-zA-Z]([-_\\.]*[0-9a-zA-Z]+)*)@([0-9a-zA-Z]([-_\\.]*[0-9a-zA-Z]+)*)[\\.]([a-zA-Z]{2,9})$/;
var add_regex = /^[0-9a-zA-Z]+$/;
var phone_regex = /^[0-9]+$/;
var date_regex = /^([0-2][0-9]|(3)[0-1])(\/)(((0)[0-9])|((1)[0-2]))(\/)\d{4}$/;
var time_regex = /^(10|11|12|[1-9]):[0-5][0-9]$/;
var pass_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/;

if (name.length == 0) {
$('#head').text("* All fields are mandatory *");
$("#id_name").focus();
return false;
}
else if (!name.match(name_regex) || name.length == 0) {
$('#p1').text("* For your name please use alphabets only *");
$("#id_name").focus();
return false;
}
else if (!phone.match(phone_regex) || phone.length != 10) {
$('#p2').text("* Please enter a valid number *");
$("#id_phone").focus();
return false;
}
else if (!email.match(email_regex) || email.length == 0) {
$('#p3').text("* Enter A Valid Email *");
$("#id_email").focus();
return false;
}
else if (!addr.match(add_regex) || addr.length == 0) {
$('#p4').text("* For Address please use numbers and letters *");
$("#id_address").focus();
return false;
}
else if (area.length == 0) {
$('#p5').text("* Please Select A District *");
$("#id_area").focus();
return false;
}
else if (local_body.length == 0) {
$('#p6').text("* Please Select A Local Body *");
$("#id_local_body").focus();
return false;
}
else if (!date.match(date_regex) || date.length == 0) {
$('#p8').text("* Enter A Valid Date in DD/MM/YYYY Format*");
$("#id_date").focus();
return false;
}
else if (!time.match(time_regex) || time.length == 0) {
$('#p9').text("* Enter A Valid time in hh:mm Format*");
$("#id_time").focus();
return false;
}
else if (!pass.match(pass_regex)) {
$('#p10').text("* Password Must contai 1 uppercase, 1 lowercase, 1number, 8charechters long*");
$("#id_password").focus();
return false;
}
else if (pass != re_pass || re_pass.length == 0) {
$('#p11').text("* Password not matching *");
$("#id_re_password").focus();
return false;
}
else if (!$('#register_consent').prop('checked')) {
$('#p12').text("* Must Agree *");
$("#register_consent").focus();
return false;
}
else {
alert("Form Submitted Successfuly!");
return true;
}
});
});

</script>

{% endblock %}
3 changes: 2 additions & 1 deletion mainapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
url(r'request_details/(?P<request_id>\d+)/$', views.request_details, name='requestdetailsview'),
path('contactus/', views.districtmanager_list, name='contactus'),
path('reg_success/', views.RegSuccess.as_view(), name='reg_successview'),
path('reg_fail/', views.RegFail.as_view(), name='reg_fail'),
path('req_sucess/', views.ReqSuccess.as_view(), name='req_sucessview'),
path('district_needs/', views.DistNeeds.as_view(), name='distneedsview'),
path('collection_center/', views.CollectionCenterView.as_view(), name='collection_centers_view'),
Expand Down Expand Up @@ -62,6 +63,6 @@
path('consent_success/', views.ConsentSuccess.as_view(), name='consent_success'),
url(r'c/(?P<pk>\d+)/(?P<ts>\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<volunteer_ph>\d+)/$', views.RenewVolunteerPage.as_view(), name='renewvolunteer'),
url('test_send_sms/', views.test_send_sms, name='test_send_sms'),

]
Loading