Skip to content

Commit

Permalink
Merge 4d4cf78 into a42fa58
Browse files Browse the repository at this point in the history
  • Loading branch information
roshan-mathewtech committed Oct 6, 2022
2 parents a42fa58 + 4d4cf78 commit a65b7fd
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Species.TaxonConceptController = Ember.ObjectController.extend Species.SearchCon
else
""
).property('citesSuspensions')
anyHistoricCitesProcesses: ( ->
if @get('citesProcesses') != undefined && @get('citesProcesses')
.findProperty('status', 'Closed') != undefined
"show_more"
else
""
).property('citesProcesses')
anyHistoricEuDecisions: ( ->
if @get('euDecisions') != undefined && @get('euDecisions')
.findProperty('is_current', false) != undefined
Expand Down Expand Up @@ -135,6 +142,18 @@ Species.TaxonConceptController = Ember.ObjectController.extend Species.SearchCon
else
null
).property('citesSuspensions')
currentCitesProcesses: (->
if @get('citesProcesses') != undefined
@get('citesProcesses').filterProperty('status', 'Ongoing').concat(@get('citesProcesses').filterProperty('status', 'Trade Suspension'))
else
null
).property('citesProcesses')
historicCitesProcesses: (->
if @get('citesProcesses') != undefined
@get('citesProcesses').filterProperty('status', 'Closed')
else
null
).property('citesProcesses')
currentEuListings: (->
if @get('euListings') != undefined
@get('euListings').filterProperty('is_current', true)
Expand Down Expand Up @@ -185,6 +204,12 @@ Species.TaxonConceptController = Ember.ObjectController.extend Species.SearchCon
else
return yes
).property('citesSuspensions')
citesProcessesIsLoading: ( ->
if @get('citesProcesses') != undefined
return no
else
return yes
).property('citesProcesses')

contentObserver: ( ->
matchedOnSelf = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Species.TaxonConcept = DS.Model.extend
citesQuotas: DS.attr("array")
citesSuspensions: DS.attr("array")
citesListings: DS.attr("array")
citesProcesses: DS.attr("array")
cmsListings: DS.attr("array")
cmsInstruments: DS.attr("array")
euListings: DS.attr("array")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<strong class="title">CITES PROCESSES</strong>
{{#unless citesProcesses}}
{{#if citesProcessesIsLoading}}
{{ partial 'species/spinner'}}
{{else}}
<p class="empty">There are no current cases for this species.</p>
{{/if}}
{{else}}
<table summary="data table">
<thead>
<tr>
<th class="col2">RESOLUTION</th>
<th class="col14">COUNTRY</th>
<th class="col2">DATE ENTRY</th>
<th class="col14">DOCUMENT</th>
<th class="col14">CASE STATUS</th>
<th class="col2">NOTES</th>
</tr>
</thead>
<tbody {{bind-attr class="controller.citesProcessExpanded:historic_expanded"}}>
{{#each process in currentCitesProcesses}}
<tr class="current">
<td>
{{process.resolution}}
</td>
<td>
{{process.geo_entity.name}}
</td>
<td>
{{process.start_event_name}} ({{process.start_date}})
</td>
<td>
</td>
<td>
{{process.status}}
</td>
<td>
{{process.notes}}
</td>
</tr>
{{else}}
<tr class="current">
<td colspan=4>There are no current cases for this species.</td>
</tr>
{{/each}}
</tbody>
</table>
{{#if historicCitesProcesses}}
<div {{bind-attr class=":historic controller.citesProcessesExpanded::hidden"}}>
<table summary="data table">
<thead>
<tr>
<th class="col2">&nbsp;</th>
<th class="col14">&nbsp;</th>
<th class="col2">&nbsp;</th>
<th class="col14">&nbsp;</th>
<th class="col14">&nbsp;</th>
<th class="col2">&nbsp;</th>
</tr>
</thead>
<tbody {{bind-attr class="controller.citesProcessExpanded:historic_expanded"}}>
{{#each process in historicCitesProcesses}}
<tr>
<td>
{{process.resolution}}
</td>
<td>
{{process.geo_entity.name}}
</td>
<td>
{{process.start_event_name}} ({{process.start_date}})
</td>
<td>
</td>
<td>
{{process.status}}
</td>
<td>
{{process.notes}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
<div {{bind-attr class=":btn-hloder citesProcessesExpanded:expanded"}}>
{{#if controller.citesProcessesExpanded}}
<a class="link active" {{action 'contractList' 'cites_processes' 'citesProcessesExpanded'}}>HIDE HISTORY</a>
{{else}}
<a class="link" {{action 'expandList' 'cites_processes' 'citesProcessesExpanded'}}>SHOW HISTORY</a>
{{/if}}
</div>
{{/if}}

{{/unless}}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
{{/with}}
</div>

<div {{bind-attr class=":block :add controllers.taxonConcept.anyHistoricCitesProcesses citesProcessesExpanded:active"}} id="cites_processes">
{{#with controllers.taxonConcept}}
{{ partial 'species/taxon_concept/cites_processes' }}
{{/with}}
</div>

<hr />

<div {{bind-attr class=":block :add controllers.taxonConcept.anyHistoricEuListings euListingsExpanded:active"}} id="eu_listings">
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/taxon_concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def show
includes(:common_names => :language,
:distributions => :geo_entity,
:quotas => :geo_entity,
:cites_suspensions => :geo_entity).
:cites_suspensions => :geo_entity,
:cites_captivity_processes => :geo_entity).
includes(:taxonomy).find(params[:id])
if @taxon_concept.taxonomy.name == Taxonomy::CMS
s = Species::ShowTaxonConceptSerializerCms
Expand Down
10 changes: 10 additions & 0 deletions app/serializers/species/cites_process_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Species::CitesProcessSerializer < ActiveModel::Serializer
attributes :resolution, { :start_date_formatted => :start_date },
:notes, :geo_entity, :status, :start_event_name


def start_event_name
object.start_event.name
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class Species::ShowTaxonConceptSerializerCites < Species::ShowTaxonConceptSerial
has_many :eu_listing_changes, :serializer => Species::EuListingChangeSerializer,
:key => :eu_listings
has_many :eu_decisions, :serializer => Species::EuDecisionSerializer
has_many :processes, :serializer => Species::CitesProcessSerializer, :key => :cites_processes

def processes
CitesCaptivityProcess.includes(:geo_entity,:start_event).where(taxon_concept_id: object.id).order(:start_date)
end

def quotas
Quota.from('api_cites_quotas_view trade_restrictions').
Expand Down

0 comments on commit a65b7fd

Please sign in to comment.