Skip to content

Commit

Permalink
Merge pull request #538 from RockefellerArchiveCenter/development
Browse files Browse the repository at this point in the history
Improves display of rights statements
  • Loading branch information
helrond authored Jun 28, 2022
2 parents 8b20113 + f933691 commit c16721a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
14 changes: 14 additions & 0 deletions bag_transfer/rights/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ class RightsStatement(models.Model):
def __str__(self):
return "{}: {}".format(self.organization, self.rights_basis)

@property
def dates_applicable_display(self):
"""Returns a display string of applicable dates for a rights statement.
Assumes that start and end dates exist on the rights statement,
in other words, assumes it is a rights statement that has been assigned
to a transfer.
"""
date_keys = self.get_date_keys(periods=True)
rights_object = self.rights_info
start_date = getattr(rights_object, date_keys[0])
end_date = getattr(rights_object, date_keys[2]) if len(date_keys) > 2 else getattr(rights_object, date_keys[1])
return f"{start_date.strftime('%b %d %Y') if start_date else 'immediately'} - {end_date.strftime('%b %d %Y') if end_date else 'no end date'}"

@property
def rights_info(self):
"""Returns the rights info object associated with a Rights Statement."""
Expand Down
2 changes: 1 addition & 1 deletion bag_transfer/templates/parts/rights_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tbody>
{% for statement in org.rights_statements %}
<tr rel="{{ statement.pk }}">
<td>{% for t in statement.applies_to_type.all %}{{t.name}}{% if not forloop.last %}<br />{%endif%}{% endfor %}</td>
<td><ul>{% for t in statement.applies_to_type.all %}<li>{{t.name}}</li>{% endfor %}</ul></td>
<td>{{statement.rights_basis}}</td>
<td>{{statement.rights_info_notes}}</td>
<td class="text-right col-md-4">
Expand Down
2 changes: 2 additions & 0 deletions bag_transfer/templates/parts/transfer_rights_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
<tr>
<th>Basis</th>
<th>Rights Notes</th>
<th>Dates Applicable</th>
</tr>
</thead>
<tbody>
{% for statement in rights_statements %}
<tr rel="{{ statement.pk }}">
<td>{{statement.rights_basis}}</td>
<td>{{statement.rights_info_notes}}</td>
<td>{{statement.dates_applicable_display}}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
30 changes: 15 additions & 15 deletions bag_transfer/templates/transfers/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ <h2 class="box-title">Error Messages</h2>
</div>
{% endif %}

{% if object.rights_statements.all %}
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header with-border">
<h2 class="box-title">Rights Statements</h2>
</div>
<div class="box-body no-padding">
{% include 'parts/transfer_rights_table.html' with rights_statements=object.rights_statements.all %}
</div>
</div>
</div>
</div>
{% endif %}

<div class="row">
<div class="col-md-12">
<div class="box box-primary">
Expand Down Expand Up @@ -92,21 +107,6 @@ <h2 class="box-title">Log</h2>
</div>
</div>

{% if object.rights_statements.all %}
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-header with-border">
<h2 class="box-title">Rights Statements</h2>
</div>
<div class="box-body no-padding">
{% include 'parts/transfer_rights_table.html' with rights_statements=object.rights_statements.all %}
</div>
</div>
</div>
</div>
{% endif %}

{% if object.archivesspace_identifier or object.archivesspace_parent_identifier %}
<div class="row">
<div class="col-md-12">
Expand Down
2 changes: 1 addition & 1 deletion scripts/import_sample_data
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Script to import set of sample bags
# Copies files to data upload directory and then runs cron

cp -r ../sample_bags/* /data/donororganization/upload/
cp -r sample_bags/* /data/donororganization/upload/
chown -R donor /data/donororganization/upload/
python manage.py runcrons bag_transfer.lib.cron.DiscoverTransfers

0 comments on commit c16721a

Please sign in to comment.