Skip to content

Commit

Permalink
Merge pull request #127 from mintcoding/working
Browse files Browse the repository at this point in the history
Working to compliance_mgt_dev
  • Loading branch information
mintcoding committed Jun 22, 2022
2 parents d5b5608 + c07089b commit 51fd92d
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUN apt-get upgrade -y

RUN apt-get install --no-install-recommends -y wget git libmagic-dev gcc \
binutils libproj-dev gdal-bin python3-setuptools python3-pip tzdata cron \
rsyslog gunicorn
rsyslog gunicorn libreoffice
RUN apt-get install --no-install-recommends -y libpq-dev patch
RUN apt-get install --no-install-recommends -y postgresql-client mtr htop \
vim
Expand Down
1 change: 1 addition & 0 deletions wildlifecompliance/components/call_email/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CallTypeAdmin(admin.ModelAdmin):
@admin.register(models.WildcareSpeciesType)
class WildcareSpeciesTypeAdmin(admin.ModelAdmin):
list_display = ['species_name', 'call_type']
exclude = ['show_species_name_textbox',]
form = forms.WildcareSpeciesTypeAdminForm

@admin.register(models.WildcareSpeciesSubType)
Expand Down
3 changes: 3 additions & 0 deletions wildlifecompliance/components/call_email/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def filter_queryset(self, request, queryset, view):
call_email.assigned_to.first_name.lower() + ' ' + call_email.assigned_to.last_name.lower()
if call_email.assigned_to else ''
)
or search_text in (call_email.wildcare_species_sub_type.species_sub_name
if call_email.wildcare_species_sub_type else ''
)
):
search_text_callemail_ids.append(call_email.id)

Expand Down
3 changes: 2 additions & 1 deletion wildlifecompliance/components/call_email/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.conf import settings
from ledger.payments.pdf import create_invoice_pdf_bytes
from ledger.payments.models import Invoice
from ledger.accounts.models import EmailUser
from wildlifecompliance.components.main.utils import get_choice_value
from wildlifecompliance.components.emails.emails import TemplateEmailBase
from wildlifecompliance.components.main.email import prepare_attachments, _extract_email_headers
Expand Down Expand Up @@ -45,7 +46,7 @@ def send_mail(select_group, call_email, workflow_entry, request=None, email_type
'call_email': call_email,
'workflow_entry_details': request.data.get('details'),
}
email_group = [item.email for item in select_group]
email_group = [item.email for item in select_group] if isinstance(select_group[0], EmailUser) else select_group
msg = email.send(email_group,
context=context,
attachments=
Expand Down
4 changes: 2 additions & 2 deletions wildlifecompliance/components/call_email/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ class CallEmail(RevisionedMixin):
)

AGE_BABY = 'baby'
AGE_ADULT = 'adult'
AGE_JUVENILE = 'juvenile'
AGE_ADULT = 'adult'
AGE_CHOICES = (
(AGE_BABY, 'Baby'),
(AGE_ADULT, 'Adult'),
(AGE_JUVENILE, 'Juvenile'),
(AGE_ADULT, 'Adult'),
)

BABY_KANGAROO_PINKY = 'pinky'
Expand Down
8 changes: 6 additions & 2 deletions wildlifecompliance/components/call_email/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ class CallEmailDatatableSerializer(serializers.ModelSerializer):
assigned_to = ComplianceUserDetailsOptimisedSerializer(read_only=True)
user_action = serializers.SerializerMethodField()
user_is_volunteer = serializers.SerializerMethodField()
species_sub_type = serializers.SerializerMethodField()

class Meta:
model = CallEmail
Expand All @@ -682,12 +683,15 @@ class Meta:
'user_action',
'user_is_volunteer',
'volunteer_id',

'species_sub_type',
)
read_only_fields = (
'id',
)


def get_species_sub_type(self, obj):
return obj.wildcare_species_sub_type.species_sub_name if obj.wildcare_species_sub_type else ''

def get_user_is_assignee(self, obj):
user_id = self.context.get('request', {}).user.id
if user_id == obj.assigned_to_id:
Expand Down
7 changes: 2 additions & 5 deletions wildlifecompliance/components/main/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ def prepare_mail(request, instance, workflow_entry, send_mail, recipient_id=None
# recipient_id is not iterable. Which means it is an id.
user = EmailUser.objects.get(id=recipient_id)
email_group.append(user)
#elif request.data.get('assigned_to_id'):
elif instance.assigned_to:
#user = EmailUser.objects.get(id=request.data.get('assigned_to_id'))
#email_group.append(user)
email_group.append(instance.assigned_to)
#elif request.data.get('allocated_group_id'):
elif instance.allocated_group and instance.allocated_group.group_email:
email_group.append(instance.allocated_group.group_email)
elif instance.allocated_group:
#compliance_group = ComplianceManagementSystemGroup.objects.get(id=request.data.get('allocated_group_id'))
email_group.extend(instance.allocated_group.get_members())
else:
request_user = getattr(request, 'user')
Expand Down
1 change: 1 addition & 0 deletions wildlifecompliance/components/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class ComplianceManagementSystemGroup(models.Model):
show_all=False,
null=True,
)
group_email = models.CharField(max_length=100, blank=True)

class Meta:
app_label = 'wildlifecompliance'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
</div>
</FormSection>

<FormSection :formCollapse="false" label="Location" Index="1">
<FormSection :formCollapse="false" label="Location *" Index="1">
<div v-if="call_email.location">
<MapLocation
:isReadonly="readonlyForm"
Expand Down Expand Up @@ -304,7 +304,7 @@
</div></div>

<div class="col-sm-12 form-group"><div class="row">
<label class="col-sm-3">Call Type</label>
<label class="col-sm-3">Call Type *</label>
<div class="col-sm-9">
<div v-for="option in call_types">
<input :disabled="readonlyForm" @change="filterWildcareSpeciesType($event,option.all_wildcare_species)" type="radio" v-bind:value="option.id" :id="'call_type_'+option.id" v-model="call_email.call_type_id">
Expand Down Expand Up @@ -379,7 +379,7 @@
</div></div>

<div class="col-sm-12 form-group"><div class="row">
<label class="col-sm-3">Female/ Male</label>
<label class="col-sm-3">Female / Male</label>
<div>
<div v-for="option in gender_choices" class="col-sm-2">
<input :disabled="readonlyForm" type="checkbox" @change="checkFemalePinkyJoey" :value="option.id" :id="'gender_'+option.id" v-bind:key="option.id" v-model="call_email.gender"/>
Expand All @@ -389,7 +389,7 @@
</div></div>

<div v-if="isFemalePinkyJoey" class="col-sm-12 form-group"><div class="row">
<label class="col-sm-3">Pinky/ Joey</label>
<label class="col-sm-3">Pinky / Joey</label>
<div>
<div v-for="option in baby_kangaroo_choices" class="col-sm-2">
<input :disabled="readonlyForm" type="checkbox" :value="option.id" :id="'babyKangaroo'+option.id" v-bind:key="option.id" v-model="call_email.baby_kangaroo"/>
Expand All @@ -409,7 +409,7 @@

<div class="col-sm-12 form-group">
<div class="row">
<label class="col-sm-3">Brief nature of call</label>
<label class="col-sm-3">Brief nature of call *</label>
<div class="col-sm-9">
<textarea :disabled="readonlyForm" class="form-control" v-model="call_email.brief_nature_of_call" />
</div>
Expand Down Expand Up @@ -1001,15 +1001,19 @@ export default {
}
}
//---filter wildcare species sub type as per species type selected
/*
if(this.speciesSubTypeDisabled === false)
{
*/
for(let choice of this.wildcare_species_sub_types){
if(choice.wildcare_species_type_id === this.call_email.wildcare_species_type_id)
{
this.filter_wildcare_species_sub_types.push(choice);
}
}
/*
}
*/
//---to reset pinky/Joey onchange of species type
this.checkFemalePinkyJoey();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@

<div class="row">
<div class="col-lg-12">
<datatable ref="call_email_table" id="call-email-table" :dtOptions="dtOptions" :dtHeaders="dtHeaders" />
<datatable
ref="call_email_table"
id="call-email-table"
:dtOptions="dtOptions"
:dtHeaders="dtHeaders"
parentStyle="wrap"
/>
</div>
</div>
</FormSection>
Expand Down Expand Up @@ -145,12 +151,17 @@
data: "status.name",
searchable: false,
},
{
data: "species_sub_type",
searchable: false,
visible: false,
},
{
data: "classification",
searchable: false,
mRender: function (data, type, full) {
if (data) {
return data.classification_display;
return data.classification_display + ': ' + full.species_sub_type;
} else {
return '';
}
Expand Down Expand Up @@ -190,6 +201,7 @@
dtHeaders: [
"Number",
"Status",
"SubSpecies",
"Classification",
"Lodged on",
"Caller",
Expand Down
26 changes: 26 additions & 0 deletions wildlifecompliance/migrations/0618_auto_20220622_1407.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2022-06-22 06:07
from __future__ import unicode_literals

from django.db import migrations, models
import multiselectfield.db.fields


class Migration(migrations.Migration):

dependencies = [
('wildlifecompliance', '0617_callemail_allocated_group'),
]

operations = [
migrations.AddField(
model_name='compliancemanagementsystemgroup',
name='group_email',
field=models.CharField(blank=True, max_length=100),
),
migrations.AlterField(
model_name='callemail',
name='age',
field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('baby', 'Baby'), ('juvenile', 'Juvenile'), ('adult', 'Adult')], max_length=30, null=True),
),
]

0 comments on commit 51fd92d

Please sign in to comment.