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

Contributor updates #817

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8be7009
add contrib updates
bjacobt Aug 21, 2018
7e4c220
add contributor update
bjacobt Aug 21, 2018
507af2f
update view, add missing fields
bjacobt Aug 21, 2018
fdd7c2b
Updated the status field.
theryecatcher Aug 21, 2018
216e400
add contrib updates
bjacobt Aug 21, 2018
eda23de
add contributor update
bjacobt Aug 21, 2018
09312b7
update view, add missing fields
bjacobt Aug 21, 2018
2488109
Updated the status field.
theryecatcher Aug 21, 2018
dfb9aaa
Updated the ContribView to have update button.
theryecatcher Aug 21, 2018
4cdfd77
Merge branch 'contributor_updates' of github.com:theryecatcher/rescue…
theryecatcher Aug 21, 2018
b87c9c9
Merge branch 'master' into contributor_updates
theryecatcher Aug 21, 2018
6779f25
Fixed Merge issues.
theryecatcher Aug 21, 2018
eb03386
MakeMigrations update for Travis.
theryecatcher Aug 21, 2018
d3370d6
Merge branch 'master' into contributor_updates
theryecatcher Aug 21, 2018
9b77cc7
add contrib updates
bjacobt Aug 21, 2018
9f0a2be
add contributor update
bjacobt Aug 21, 2018
cca3d30
update view, add missing fields
bjacobt Aug 21, 2018
97f2560
Updated the status field.
theryecatcher Aug 21, 2018
7e14132
add contrib updates
bjacobt Aug 21, 2018
5f92d3e
Updated the status field.
theryecatcher Aug 21, 2018
5dc045c
Updated the ContribView to have update button.
theryecatcher Aug 21, 2018
a30535e
Fixed Merge issues.
theryecatcher Aug 21, 2018
b03542a
MakeMigrations update for Travis.
theryecatcher Aug 21, 2018
a2c2e4c
Phone Number visible only for Authenticated users.
theryecatcher Aug 21, 2018
5f58e56
Merged Migrations.
theryecatcher Aug 21, 2018
5c4e32b
Merge branch 'contributor_updates' of github.com:theryecatcher/rescue…
theryecatcher Aug 21, 2018
1e997af
Merge branch 'master' into contributor_updates
theryecatcher Aug 21, 2018
a677a9d
Again MakeMigrations merge.
theryecatcher Aug 21, 2018
d99c24b
Merge branch 'master' into contributor_updates
theryecatcher Aug 21, 2018
e04ae2e
:( Update MakeMigrations.
theryecatcher Aug 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mainapp/migrations/0062_contributorupdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.1 on 2018-08-21 06:54

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0061_auto_20180820_1010'),
]

operations = [
migrations.CreateModel(
name='ContributorUpdate',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.CharField(choices=[('hig', 'High priority'), ('med', 'Medium priority'), ('low', 'Low priority'), ('cls', 'Can be closed'), ('otr', 'Other')], max_length=10)),
('other_status', models.CharField(blank=True, default='', max_length=255, verbose_name='Please specify other status')),
('updater_name', models.CharField(max_length=100, verbose_name='Name of person or group updating')),
('updater_phone', models.CharField(max_length=14, validators=[django.core.validators.RegexValidator(code='invalid_mobile', message='Please Enter 10/11 digit mobile number or landline as 0<std code><phone number>', regex='^((\\+91|91|0)[\\- ]{0,1})?[456789]\\d{9}$')], verbose_name='Phone number of person or group updating')),
('notes', models.TextField(blank=True, verbose_name='Contributor comments')),
('update_ts', models.DateTimeField(auto_now_add=True)),
('contributor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='mainapp.Contributor')),
],
),
]
14 changes: 14 additions & 0 deletions mainapp/migrations/0065_merge_20180821_1426.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1 on 2018-08-21 08:56

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0062_contributorupdate'),
('mainapp', '0064_privaterescuecamp'),
]

operations = [
]
14 changes: 14 additions & 0 deletions mainapp/migrations/0066_merge_20180821_1500.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1 on 2018-08-21 09:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0065_merge_20180821_1422'),
('mainapp', '0065_merge_20180821_1426'),
]

operations = [
]
14 changes: 14 additions & 0 deletions mainapp/migrations/0069_merge_20180821_2300.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1 on 2018-08-21 17:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0066_merge_20180821_1500'),
('mainapp', '0068_auto_20180821_1710'),
]

operations = [
]
14 changes: 14 additions & 0 deletions mainapp/migrations/0073_merge_20180822_0018.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1 on 2018-08-21 18:48

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0069_merge_20180821_2300'),
('mainapp', '0072_auto_20180822_0000'),
]

operations = [
]
14 changes: 14 additions & 0 deletions mainapp/migrations/0074_merge_20180822_0024.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1 on 2018-08-21 18:54

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('mainapp', '0073_merge_20180822_0018'),
('mainapp', '0073_merge_20180822_0015'),
]

operations = [
]
49 changes: 47 additions & 2 deletions mainapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
('M', 'Medium'),
('L', 'Low')]


contributor_update_status_types = (
('hig', 'High priority'),
('med', 'Medium priority'),
('low', 'Low priority'),
('cls', 'Can be closed'),
('otr', 'Other')
)

person_status = (
('new', 'New'),
('checked_out', 'Checked Out'),
Expand All @@ -96,7 +105,6 @@ class LSGTypes(Enum):
MUNICIPALITY = 1
GRAMA_PANCHAYATH = 2


class Request(models.Model):
district = models.CharField(
max_length = 15,
Expand Down Expand Up @@ -529,14 +537,51 @@ class RequestUpdate(models.Model):

phone_number_regex = RegexValidator(regex='^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$', message='Please Enter 10/11 digit mobile number or landline as 0<std code><phone number>', code='invalid_mobile')
updater_phone = models.CharField(max_length=14,verbose_name='Phone number of person or group updating', validators=[phone_number_regex])

notes = models.TextField(verbose_name='Volunteer comments', blank=True)
update_ts = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.get_status_display()


class ContributorUpdate(models.Model):
contributor = models.ForeignKey(Contributor, on_delete=models.CASCADE)
status = models.CharField(
max_length = 10,
choices = contrib_status_types,
default = 'new'
)

other_status = models.CharField(max_length=255, verbose_name='Please specify other status', default='', blank=True)
updater_name = models.CharField(max_length=100, verbose_name='Name of person or group updating', blank=False)

phone_number_regex = RegexValidator(regex='^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$', message='Please Enter 10/11 digit mobile number or landline as 0<std code><phone number>', code='invalid_mobile')
updater_phone = models.CharField(max_length=14,verbose_name='Phone number of person or group updating', validators=[phone_number_regex])
notes = models.TextField(verbose_name='Contributor comments', blank=True)
update_ts = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.get_status_display()

class ContributorUpdate(models.Model):
contributor = models.ForeignKey(Contributor, on_delete=models.CASCADE)
status = models.CharField(
max_length = 10,
choices = contrib_status_types,
default = 'new'
)

other_status = models.CharField(max_length=255, verbose_name='Please specify other status', default='', blank=True)
updater_name = models.CharField(max_length=100, verbose_name='Name of person or group updating', blank=False)

phone_number_regex = RegexValidator(regex='^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}$', message='Please Enter 10/11 digit mobile number or landline as 0<std code><phone number>', code='invalid_mobile')
updater_phone = models.CharField(max_length=14,verbose_name='Phone number of person or group updating', validators=[phone_number_regex])
notes = models.TextField(verbose_name='Contributor comments', blank=True)

update_ts = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.get_status_display()

class CollectionCenter(models.Model):

Expand Down
10 changes: 8 additions & 2 deletions mainapp/templates/mainapp/contrib_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,27 @@ <h2 class="text-center">malayalam placeholder</h2>
<tr>
<th>District - ജില്ല</th>
<th>Name - ml</th>
<th>Phone - ഫോണ്‍ നമ്പര്‍</th>
{% if user.is_authenticated %}
<th>Phone - ഫോണ്‍ നമ്പര്‍</th>
{% endif %}
<th>address -ml-</th>
<th>commodities -ml-</th>
<th>Status -ml-</th>
<th>Update</th>
</tr>
</thead>
<tbody>
{% for req in data %}
<tr>
<td>{{ req.get_district_display }}</td>
<td>{{ req.name }}</td>
<td>{{ req.phone }}</td>
{% if user.is_authenticated %}
<td>{{ req.phone }}</td>
{% endif %}
<td>{{ req.address }}</td>
<td>{{ req.commodities }}</td>
<td>{{ req.get_status_display }}</td>
<td><a class="btn btn-sm btn-success" href="{%url 'contributorupdateview' req.id %}" target="_blank">Update</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down
110 changes: 110 additions & 0 deletions mainapp/templates/mainapp/contributor_update.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block content %}


<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th colspan="2" style="text-align:center;"><h3>Contributor Info</h3></th>
</tr>
</thead>

<tbody>
<tr>
<td><b> District : </b></td><td>{{ view.contributor.district }}</td>
</tr>
<tr>
<td><b> Name : </b></td><td>{{ view.contributor.name }}</td>
</tr>
{% if user.is_authenticated %}
<tr>
<td><b> Phone : </b></td><td>{{ view.contributor.phone }}</td>
</tr>
{% endif %}
<tr>
<td><b> Address : </b></td><td>{{ view.contributor.address }}</td>
</tr>
<tr>
<td><b> Commodities : </b></td><td>{{ view.contributor.commodities }}</td>
</tr>
<tr>
<td><b> Status : </b></td><td>{{ view.contributor.status }}</td>
</tr>

</tbody>
</table>

</div>

<h3 style="text-align:center;">Updates</h3>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Status</th>
<th>Updater Name</th>
{% if user.is_authenticated %}
<th>Updater Phone</th>
{% endif %}
<th>Notes</th>
<th>Update Time</th>
</tr>
</thead>

<tbody>

{% for update in view.updates %}
<tr>
<td>{{ update.status }} {{ update.other_status }}</td>
<td>{{ update.updater_name }}</td>
{% if user.is_authenticated %}
<td>{{ update.updater_phone }}</td>
{% endif %}
<td>{{ update.notes }}</td>
<td>{{ update.update_ts }}</td>
</tr>
{% endfor %}

</tbody>
</table>

</div>

<h1 class="text-center">Contributor Updates</h1>
<h2 class="text-center">placeholder for malayalam ‍</h2>
<form method="post" class="simple-form" id="contributor_update_form">
{% csrf_token %}
{% bootstrap_form form %}

{% buttons %}
<button type="submit" class="btn btn-primary">
{% bootstrap_icon "star" %} Submit
</button>
{% endbuttons %}
</form>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("[name=other_status]").attr('type', 'hidden');
$("[name=other_status]").attr('required', 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('required', false)
// $("[for=id_other_status]").hide();
} else {
$("[name=other_status]").attr('type', 'text')
// $("[for=id_other_status]").show();
}
})

</script>
{% endblock %}
9 changes: 9 additions & 0 deletions mainapp/templates/mainapp/contributor_update_success.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">Thank You for updating Contributor info</h3>
<h3 align="center">Malayalam placeholder</h3>

{% endblock %}
2 changes: 2 additions & 0 deletions mainapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@
path('req_update_success/', views.ReqUpdateSuccess.as_view(), name='req_update_success'),
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(r'contributor_update/(?P<contributor_id>\d+)/$', views.ContributorUpdateView.as_view(), name='contributorupdateview'),
path('contributor_update_success/', views.ContributorUpdateSuccess.as_view(), name='contributor_update_success')
]
Loading