Skip to content

Commit

Permalink
Merge pull request #201 from JohnMulligan/late_august_2023_patches
Browse files Browse the repository at this point in the history
Late august 2023 patches
  • Loading branch information
derekjkeller authored Nov 2, 2023
2 parents 408772f + 0cb8c31 commit 69e05c4
Show file tree
Hide file tree
Showing 30 changed files with 760 additions and 68 deletions.
128 changes: 128 additions & 0 deletions docker-compose-as.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
version: "3.7"

services:
voyages-mysql:
image: "mysql:8.0.23"
platform: "linux/amd64"
cap_add:
- SYS_NICE # CAP_SYS_NICE
container_name: "voyages-mysql"
hostname: "voyages-mysql"
restart: "on-failure"
ports:
- "3306:3306"
networks:
- "voyages"
volumes:
- "mysql_volume:/var/lib/mysql"
command: --slow-query-log=ON --long-query-time=3 --slow-query-log-file=/tmp/slow.log
environment:
MYSQL_ROOT_PASSWORD: "voyages"

voyages-solr:
image: "solr:8.5.2"
container_name: "voyages-solr"
hostname: "voyages-solr"
restart: "on-failure"
ports:
- "8983:8983"
networks:
- "voyages"
volumes:
- "solr_volume:/var/solr"
- "./solr:/srv/voyages/solr"
environment:
SOLR_JAVA_MEM: "-Xms1g -Xmx1g"

voyages-redis:
image: "redis:3.2.12-alpine"
container_name: "voyages-redis"
hostname: "voyages-redis"
restart: "on-failure"
ports:
- "6379:6379"
networks:
- "voyages"
volumes:
- "redis_volume:/data"

voyages-django:
image: "voyages-django"
container_name: "voyages-django"
hostname: "voyages-django"
restart: "on-failure"
depends_on:
- "voyages-mysql"
- "voyages-solr"
- "voyages-redis"
ports:
- "8000:8000"
networks:
- "voyages"
volumes:
- ".:/srv/voyages"
- "./documents:/mnt/sv_share/documents"
- "./voyages/sitemedia:/mnt/sv_share/sitemedia"
- "./voyages/static:/mnt/sv_share/static"
build:
context: "."
dockerfile: "./docker/django/Dockerfile"

voyages-nginx:
image: "nginx:1.19.8-alpine"
container_name: "voyages-nginx"
hostname: "voyages-nginx"
restart: "on-failure"
depends_on:
- "voyages-django"
ports:
- "8100:80"
networks:
- "voyages"
volumes:
- "./docker/nginx/conf.d:/etc/nginx/conf.d"
- "./documents:/mnt/sv_share/documents"
- "./voyages/sitemedia:/mnt/sv_share/sitemedia"
- "./voyages/static:/mnt/sv_share/static"

voyages-adminer:
image: "adminer:latest"
container_name: "voyages-adminer"
hostname: "voyages-adminer"
restart: "on-failure"
depends_on:
- "voyages-mysql"
ports:
- "8080:8080"
networks:
- "voyages"

voyages-mailhog:
image: "mailhog/mailhog:latest"
platform: "linux/amd64"
container_name: "voyages-mailhog"
hostname: "voyages-mailhog"
restart: "on-failure"
depends_on:
- "voyages-django"
ports:
- "1025:1025"
- "8025:8025"
networks:
- "voyages"
logging:
driver: "none"

networks:
voyages:
driver: "bridge"
ipam:
driver: "default"
config:
- subnet: "172.20.0.0/16"

volumes:
mysql_volume: {}
solr_volume: {}
redis_volume: {}
7 changes: 4 additions & 3 deletions docker/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ FROM ubuntu:18.04 AS base
RUN apt-get update -y \
&& apt-get install --yes --no-upgrade --no-install-recommends \
gettext=0.19.8.1-6ubuntu0.3 \
mysql-client=5.7.41-0ubuntu0.18.04.1 \
libmysqlclient-dev=5.7.41-0ubuntu0.18.04.1 \
mysql-client=5.7.42-0ubuntu0.18.04.1 \
libmysqlclient-dev=5.7.42-0ubuntu0.18.04.1 \
python3=3.6.7-1~18.04 \
python3-pip=9.0.1-2.3~ubuntu1.18.04.8 \
python3-future=0.15.2-4ubuntu2 \
Expand All @@ -30,9 +30,10 @@ FROM base AS build
RUN apt-get update \
&& apt-get install --yes --no-upgrade --no-install-recommends \
gcc=4:7.4.0-1ubuntu2.3 \
libxml2-dev=2.9.4+dfsg1-6.1ubuntu1.8 \
libxml2-dev=2.9.4+dfsg1-6.1ubuntu1.9 \
libxslt1-dev=1.1.29-5ubuntu0.3 \
python3-dev=3.6.7-1~18.04 \
build-essential \
&& apt-get clean \
&& rm -rf \
/tmp/* \
Expand Down
6 changes: 6 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ Build and run the containers necessary to work on the project.
For details, see `docker-compose.yml`.

```bash
# Without Apple Silicon
host:~/Projects/voyages$ docker-compose up -d --build

# With Apple Silicon
#
# Go to Docker Desktop settings > Features in Development > Enable "Use Rosetta" > Click "Apply & Restart"
host:~/Projects/voyages$ docker-compose -f docker-compose-as.yml up -d --build
```

Create the database. Note: append a suffix for the branch (e.g.
Expand Down
26 changes: 15 additions & 11 deletions voyages/apps/contribute/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
ReviewRequest,
ReviewRequestDecision)
from voyages.apps.past.models import VoyageCaptainOwnerHelper
from voyages.apps.voyage.models import (Voyage, VoyageCaptain,
VoyageCaptainConnection, VoyageCargoConnection, VoyageCrew,
VoyageDataset, VoyageDates,
from voyages.apps.voyage.models import (Voyage,
VoyageCargoConnection, VoyageCrew,
VoyageDates,
VoyageItinerary, VoyageOutcome,
VoyagesFullQueryHelper, VoyageShip,
VoyageShipOwner,
VoyageShipOwnerConnection,
VoyageSlavesNumbers, VoyageSources,
VoyageSourcesConnection)

if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE <= 2:
from voyages.apps.voyage.models import (VoyageCaptain, VoyageCaptainConnection, VoyageShipOwner, VoyageShipOwnerConnection)

CARGO_COLUMN_COUNT = 10

_exported_spss_fields = [
Expand Down Expand Up @@ -931,9 +932,10 @@ def _save_editorial_version(review_request,
_delete_child_fk(voyage, 'voyage_crew')
_delete_child_fk(voyage, 'voyage_slaves_numbers')
voyage.voyage_name_outcome.clear()
voyage.voyage_captain.clear()
voyage.voyage_ship_owner.clear()
voyage.voyage_sources.clear()
if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE <= 2:
voyage.voyage_captain.clear()
voyage.voyage_ship_owner.clear()

voyage.dataset = review_request.dataset
voyage.comments = interim.voyage_comments
Expand Down Expand Up @@ -979,7 +981,7 @@ def create_ship_owner(owner_name, order):
conn.owner_order = order
conn.voyage = voyage
conn.save()
if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE <= 2:
if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE >= 2:
# TODO detect existing alias/identity and create connection or
# create new identity/alias if needed.
pass
Expand All @@ -1003,7 +1005,7 @@ def create_captain(name, order):
conn.captain_order = order
conn.voyage = voyage
conn.save()
if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE <= 2:
if settings.VOYAGE_ENSLAVERS_MIGRATION_STAGE >= 2:
# TODO detect existing alias/identity and create connection or
# create new identity/alias if needed.
pass
Expand Down Expand Up @@ -1367,19 +1369,21 @@ def create_source_reference(short_ref, conn_ref, order):
source_order)
source_order += 1

Voyage.african_info.through.objects.filter(voyage=voyage).delete()
if interim.african_info:
afrinfo = json.loads(interim.african_info)
for a in afrinfo:
afrinfo_conn = Voyage.african_info.through(voyage_id=voyage.voyage_id, africaninfo_id=a)
afrinfo_conn.save()
VoyageCargoConnection.objects.filter(voyage=voyage).delete()
if interim.cargo:
cargo = json.loads(interim.cargo)
for c in cargo:
cargo_conn = VoyageCargoConnection()
cargo_conn.voyage = voyage
cargo_conn.cargo_id = c['cargo_type']
cargo_conn.unit_id = c['unit']
cargo_conn.amount = c['amount']
cargo_conn.unit_id = c.get('unit')
cargo_conn.amount = c.get('amount')
cargo_conn.save()

# Set voyage foreign keys (this is redundant, but we are keeping the
Expand Down
26 changes: 26 additions & 0 deletions voyages/apps/contribute/templates/contribute/decision_part.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ <h3>{% trans "Editorial tools:" %}</h3>
{% if allow_impute %}
<button class="btn btn-solid" type="submit" id="impute_btn">{% trans "Impute" %}</button>
{% endif %}
<button class="btn btn-danger" type="submit" id="delete_this_review">{% trans "Delete this editorial review" %}</button>
</div>
{% endif %}
{% elif mode == 'editorial_review' or mode == 'editor' %}
Expand Down Expand Up @@ -156,6 +157,7 @@ <h3>{% trans "Editorial tools:" %}</h3>
numbers['interim_slave_number_' + key.toUpperCase()] = dict[key];
}
}
console.log(text);
alert('{% trans "Impute variables computed as follows" %}: ' + text);
// Reload page and expand all sections.
window.location.href = window.location.href + '?expandAllSections=true' +
Expand All @@ -175,6 +177,30 @@ <h3>{% trans "Editorial tools:" %}</h3>
});
{% endif %}
{% with editor_contribution=review_request.editor_contribution.first %}
$('#delete_this_review').click(function() {
if (!confirm('Are you sure you want to delete this review?')) {
return;
}
var self = $(this);
$.ajax({
type: "POST",
url: '/contribute/editorial_review/{{ editor_contribution.pk }}/delete_editorial_review',
success: function (response) {
if (response.result == 'OK') {
window.location.replace("{% url 'contribute:editor_main' %}?tab=requests");
} else {
alert(response.errors);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Error deleting: ' + textStatus);
},
complete: function() {
self.prop('disabled', false);
}
});
return false;
});
$('#submit_final_decision_btn').click(function() {
var decision = parseInt($('#editorial_decision option:selected').val());
if (decision != 3 && decision != 4 && decision != 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</script>
{% endif %}
{% if mode == 'editor' %}
<a id="return_btn" class="btn btn-default" href="/contribute/editor_main?tab=requests">{% trans "Return to requests list" %}</a>
<a id="return_btn" class="btn btn-outline" href="/contribute/editor_main?tab=requests">{% trans "Return to requests list" %}</a>
{% endif %}


Expand Down
3 changes: 2 additions & 1 deletion voyages/apps/contribute/templates/contribute/interim.html
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ <h3>{% trans "Current source references" %}</h3>
{% endif %}
</form>
{% if mode == 'editorial_review' %}
<a id="return_btn" class="btn btn-default" href="/contribute/editor_main?tab=requests">{% trans "Return to requests list" %}</a>
<a id="return_btn" class="btn btn-outline" href="/contribute/editor_main?tab=requests">{% trans "Return to requests list" %}</a>
{% endif %}
{% if mode == 'review' %}
<a id="return_btn" class="btn btn-default" href="/contribute">{% trans "Return to Contribute home" %}</a>
Expand Down Expand Up @@ -2091,6 +2091,7 @@ <h4 class="modal-title" id="create_cargo_dialog_label">{% trans "Add cargo to vo
return getMonthLocaleName(locale, i);
};
var leadingZero = function(d) {
d = parseInt(d);
return d < 10 ? '0' + d : '' + d;
};
for (var i = 1; i <= 12; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ <h3>{% trans "Contributor" %}</h3>
var date = dateFormat($this.html());
$this.html(date);
if (date == '') {
$this.parent().addClass('blank');
$this.parent().children('span').addClass('blank');
}
});

Expand Down Expand Up @@ -1012,7 +1012,7 @@ <h3>{% trans "Contributor" %}</h3>
color: lightgray;
}

.blank > span:after {
.blank > span:after, span.blank:after {
color: gray;
content: '{% trans "(blank)" %}';
}
Expand Down
4 changes: 4 additions & 0 deletions voyages/apps/contribute/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
r'/submit_editorial_decision',
views.submit_editorial_decision,
name='submit_editorial_decision'),
url(r'editorial_review/(?P<editor_contribution_id>\d+)'
r'/delete_editorial_review',
views.delete_editorial_review,
name='delete_editorial_review'),
url(r'editorial_review/(?P<review_request_id>\d+)',
views.editorial_review,
name='editorial_review'),
Expand Down
Loading

0 comments on commit 69e05c4

Please sign in to comment.