Skip to content

Commit

Permalink
Merge pull request #563 from WebarchivCZ/master
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
westfood committed Dec 9, 2020
2 parents fef9694 + e5f1c75 commit e63eed5
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 50 deletions.
8 changes: 6 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ pipeline {
cd ci
ansible-playbook -i test prepare-configuration.yml
docker-compose -f docker-compose-test.yml -p seeder pull
docker-compose -f docker-compose-test.yml -p seeder up -d --remove-orphans
docker-compose -f docker-compose-test.yml -p seeder rm --stop --force web static
docker volume rm seeder_static
docker-compose -f docker-compose-test.yml -p seeder up -d
'''
}
}
Expand All @@ -59,7 +61,9 @@ pipeline {
ansible-playbook -i prod --private-key ${SSH_CREDS} -u ${SSH_CREDS_USR} prepare-configuration.yml
# I had issues witch docker_compose module in ansible. Thus implmentation in ssh as workaround.
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 docker-compose -f docker-compose-prod.yml -p seeder pull
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 docker-compose -f docker-compose-prod.yml -p seeder up -d --remove-orphans
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 docker-compose -f docker-compose-prod.yml -p rm --stop --force web static
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 docker volume rm seeder_static
ssh -o "StrictHostKeyChecking=no" -i ${SSH_CREDS} ${SSH_CREDS_USR}@10.3.0.50 docker-compose -f docker-compose-prod.yml -p seeder up -d
'''
}
}
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Seeder
======
# Seeder

[![Code Health](https://landscape.io/github/WebarchivCZ/Seeder/master/landscape.svg?style=flat)](https://landscape.io/github/WebarchivCZ/Seeder/master)
[![Build Status](https://travis-ci.org/WebArchivCZ/Seeder.svg?branch=master)](https://travis-ci.org/WebArchivCZ/Seeder)
Expand All @@ -14,7 +13,10 @@ archived and what parts should die in the shadows of unarchived wasteland.

Documentation is available at [Read the docs](http://seeder.readthedocs.org/en/latest/).

Docker compose should work out of box after cloning. Run: ```docker-compose up```.
## Production like environment
Docker compose should work out of box after cloning. Run: ```docker-compose up```. Docker-compose mimics production deployment. So important note is you should ```docker volume rm static``` otherwise static_root volume persists and both nginx and django will not show latest output from collectstatic. Or just run ```./local``` which will always delete nginx and django container and static is corectly deployed.

Check [http://localhost](http://localhost) for Seeder, and [http://localhost:8080](http://localhost:8080) for Traefik.

[Webarchiv.cz deployment instructions](ci/README.md)

Expand Down
19 changes: 19 additions & 0 deletions Seeder/contracts/migrations/0006_auto_20201207_1653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.13 on 2020-12-07 16:53

import contracts.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('contracts', '0005_remove_contract_creative_commons'),
]

operations = [
migrations.AlterField(
model_name='contract',
name='year',
field=models.PositiveIntegerField(default=contracts.models.this_year, verbose_name='Year'),
),
]
2 changes: 1 addition & 1 deletion Seeder/contracts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Contract(BaseModel):

year = models.PositiveIntegerField(
_('Year'),
default=this_year()
default=this_year
)

contract_file = models.FileField(
Expand Down
3 changes: 2 additions & 1 deletion Seeder/contracts/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
class ContractTable(tables.Table):
link = AbsoluteURLColumn(
accessor='__str__',
verbose_name=_('link')
verbose_name=_('link'),
order_by=('-year', '-contract_number'),
)
publisher = AbsoluteURLColumn(
accessor='publisher',
Expand Down
4 changes: 2 additions & 2 deletions Seeder/core/dashboard_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ class WithoutAleph(SourceCard):

def get_queryset(self):
return self.get_basic_queryset().filter(
Q(aleph_id='') | Q(aleph_id=None),
state=source_models.constants.STATE_RUNNING,
aleph_id__exact=''
)


Expand Down Expand Up @@ -222,7 +222,7 @@ def get_queryset(self):
tries < source_models.constants.RANDOM_QA_MAX_TRIES
):
tries += 1
s = qa_sources[random.randint(0, qa_sources.count()-1)]
s = qa_sources[random.randint(0, qa_sources.count() - 1)]
random_qa.add(s.pk)
# Order these by date so that the first item is the oldest
return source_models.Source.objects.filter(
Expand Down
36 changes: 20 additions & 16 deletions Seeder/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Seeder\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-03 08:11+0000\n"
"POT-Creation-Date: 2020-12-07 17:02+0000\n"
"PO-Revision-Date: 2018-04-16 13:40+0200\n"
"Last-Translator: mariehaskovcova <marie.haskovcova@nkp.cz>, 2017\n"
"Language-Team: Czech (https://www.transifex.com/webarchivecz/teams/43032/"
Expand Down Expand Up @@ -269,15 +269,15 @@ msgstr "Kdy chcete odeslat tuto zprávu?"
msgid "link"
msgstr "Odkaz"

#: contracts/tables.py:16
#: contracts/tables.py:17
msgid "publisher"
msgstr "Vydavatel"

#: contracts/tables.py:18 qa/tables.py:10 templates/api.html:17
#: contracts/tables.py:19 qa/tables.py:10 templates/api.html:17
msgid "created"
msgstr "Vytvořeno"

#: contracts/tables.py:19 qa/tables.py:11
#: contracts/tables.py:20 qa/tables.py:11
msgid "last_changed"
msgstr "Naposledy upraveno"

Expand Down Expand Up @@ -427,39 +427,39 @@ msgstr "Nelze smazat smlouvu s číslem"
msgid "Contract deleted."
msgstr "Smlouva smazána"

#: core/dashboard_data.py:67
#: core/dashboard_data.py:68
msgid "Contracts in negotiation"
msgstr "Smlouvy v jednání"

#: core/dashboard_data.py:87
#: core/dashboard_data.py:88
msgid "Contracts without scheduled communication"
msgstr "Smlouvy bez rozvrhnutého jednání"

#: core/dashboard_data.py:114
#: core/dashboard_data.py:115
msgid "Voting rounds you manage"
msgstr "Hodnocení, která spravujete"

#: core/dashboard_data.py:134
#: core/dashboard_data.py:135
msgid "Open voting rounds"
msgstr "Otevřená hodnocení"

#: core/dashboard_data.py:161
#: core/dashboard_data.py:162
msgid "Sources curating"
msgstr "Zdroje, které spravujete"

#: core/dashboard_data.py:173
#: core/dashboard_data.py:174
msgid "Sources that need technical review"
msgstr "Zdroje, které potřebují technický dohled"

#: core/dashboard_data.py:182
#: core/dashboard_data.py:183
msgid "Source without Aleph ID"
msgstr "Zdroje ke katalogizaci"

#: core/dashboard_data.py:192
#: core/dashboard_data.py:193
msgid "Opened QAs"
msgstr "Rozpracovaná kontrola kvality"

#: core/dashboard_data.py:205
#: core/dashboard_data.py:206
msgid "Sources needing QA"
msgstr "Zdroje ke kontrole"

Expand Down Expand Up @@ -1664,6 +1664,10 @@ msgstr "aktuality"
msgid "Webarchiv certificate"
msgstr "Webarchiv certificate"

#: www/templates/categories/menu.html:50
msgid "Můžete hledat i abecedně"
msgstr "Můžete hledat i abecedně"

#: www/templates/news_admin_detail.html:32
msgid "source 1 "
msgstr "první zdroj "
Expand Down Expand Up @@ -1816,17 +1820,17 @@ msgstr "^certifikovano/$"
msgid "^embed_url$"
msgstr "^embed$"

#: www/views.py:427
#: www/views.py:441
#, python-format
msgid "Webarchiv.cz - archivace vasich webovych stranek %(url)s"
msgstr "Webarchiv.cz - archivace Vašich webových stránek %(url)s"

#: www/views.py:431
#: www/views.py:445
#, python-format
msgid "Webarchiv.cz - archivace webovych stranek %(url)s"
msgstr "Webarchiv.cz - archivace webových stránek %(url)s"

#: www/views.py:453
#: www/views.py:467
#, python-format
msgid "New nomination %(url)s"
msgstr "Nový návrh %(url)s"
36 changes: 20 additions & 16 deletions Seeder/locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Seeder\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-03 08:11+0000\n"
"POT-Creation-Date: 2020-12-07 17:02+0000\n"
"PO-Revision-Date: 2017-11-07 12:38+0100\n"
"Last-Translator: Visgean Skeloru <visgean@gmail.com>, 2017\n"
"Language-Team: English (United States) (https://www.transifex.com/"
Expand Down Expand Up @@ -270,15 +270,15 @@ msgstr "When to send this message"
msgid "link"
msgstr "Link"

#: contracts/tables.py:16
#: contracts/tables.py:17
msgid "publisher"
msgstr "Publisher"

#: contracts/tables.py:18 qa/tables.py:10 templates/api.html:17
#: contracts/tables.py:19 qa/tables.py:10 templates/api.html:17
msgid "created"
msgstr "Created"

#: contracts/tables.py:19 qa/tables.py:11
#: contracts/tables.py:20 qa/tables.py:11
msgid "last_changed"
msgstr "Last_changed"

Expand Down Expand Up @@ -430,39 +430,39 @@ msgstr "Can't delete contract with number"
msgid "Contract deleted."
msgstr "Contract deleted."

#: core/dashboard_data.py:67
#: core/dashboard_data.py:68
msgid "Contracts in negotiation"
msgstr "Contracts in negotiation"

#: core/dashboard_data.py:87
#: core/dashboard_data.py:88
msgid "Contracts without scheduled communication"
msgstr "Contracts without scheduled communication"

#: core/dashboard_data.py:114
#: core/dashboard_data.py:115
msgid "Voting rounds you manage"
msgstr "Voting rounds you manage"

#: core/dashboard_data.py:134
#: core/dashboard_data.py:135
msgid "Open voting rounds"
msgstr "Open voting rounds"

#: core/dashboard_data.py:161
#: core/dashboard_data.py:162
msgid "Sources curating"
msgstr "Sources curating"

#: core/dashboard_data.py:173
#: core/dashboard_data.py:174
msgid "Sources that need technical review"
msgstr "Sources that need technical review"

#: core/dashboard_data.py:182
#: core/dashboard_data.py:183
msgid "Source without Aleph ID"
msgstr "Source without Aleph ID"

#: core/dashboard_data.py:192
#: core/dashboard_data.py:193
msgid "Opened QAs"
msgstr "Opened QAs"

#: core/dashboard_data.py:205
#: core/dashboard_data.py:206
msgid "Sources needing QA"
msgstr "Sources needing QA"

Expand Down Expand Up @@ -1670,6 +1670,10 @@ msgstr "news"
msgid "Webarchiv certificate"
msgstr "Webarchiv certificate"

#: www/templates/categories/menu.html:50
msgid "Můžete hledat i abecedně"
msgstr "You can also search alphabetically"

#: www/templates/news_admin_detail.html:32
msgid "source 1 "
msgstr "source 1 "
Expand Down Expand Up @@ -1822,17 +1826,17 @@ msgstr "^disclaimer/$"
msgid "^embed_url$"
msgstr "^embed$"

#: www/views.py:427
#: www/views.py:441
#, python-format
msgid "Webarchiv.cz - archivace vasich webovych stranek %(url)s"
msgstr "Webarchiv.cz - web archiving your pages %(url)s"

#: www/views.py:431
#: www/views.py:445
#, python-format
msgid "Webarchiv.cz - archivace webovych stranek %(url)s"
msgstr "Webarchiv.cz - web archiving %(url)s"

#: www/views.py:453
#: www/views.py:467
#, python-format
msgid "New nomination %(url)s"
msgstr "New nomination %(url)s"
6 changes: 4 additions & 2 deletions Seeder/source/field_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import django_filters

from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from dal import autocomplete
from core.custom_filters import BaseFilterSet, DateRangeFilter
Expand All @@ -15,18 +15,20 @@ def filter_not_empty(queryset, name, value):
return q.exclude(**{lookup_empty: ''})
else:
empty = queryset.filter(
aleph_id__exact='').values_list('pk', flat=True)
Q(aleph_id='') | Q(aleph_id=None)).values_list('pk', flat=True)
null = q.values_list('pk', flat=True)
return queryset.filter(pk__in=list(empty) + list(null))


def filter_has_cc(queryset, name, value):
return models.Source.objects.has_cc(value)


def filter_contract_number(queryset, name, value):
# value in format e.g. '64 / 2017'
return models.Source.objects.contains_contract_number(value)


class SourceFilter(BaseFilterSet):
publisher = django_filters.ModelChoiceFilter(
queryset=Publisher.objects.all(),
Expand Down
3 changes: 2 additions & 1 deletion Seeder/www/templates/categories/menu.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load i18n %}
{% load urltags %}
<section id="catalog-header">
<div class="container">
Expand Down Expand Up @@ -46,7 +47,7 @@ <h2 class="italic">{{ current_category }} / {{ current_sub_category }}</h2>
{% endfor %}
</ul>
{% else %}
<h2 class="italic">Můžete hledat i abecedně</h2>
<h2 class="italic">{% trans "Můžete hledat i abecedně" %}</h2>
<ul class="inline-list subcategories">
<li>
<a href="{% url "www:categories" %}" {% if not current_sub_category %}class="current"
Expand Down
2 changes: 1 addition & 1 deletion ci/templates/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:
working_dir: /code/Seeder
volumes:
- "media:/code/Seeder/media"
- "static:/code/Seeder/static"
- "static:/code/Seeder/static_root"
labels:
- "traefik.http.routers.seeder.rule={{ treafik_seeder_rule }}"
environment:
Expand Down
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
context: .
volumes:
- .:/code
- "static:/code/Seeder/static"
- "static:/code/Seeder/static_root"
- "media:/code/Seeder/media"
command: bash run.sh
working_dir: /code/Seeder
Expand All @@ -43,15 +43,14 @@ services:
static:
image: nginx:alpine
volumes:
- static:/seeder/static
- media:/seeder/media
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- static:/seeder/static:ro
- media:/seeder/media:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
labels:
traefik.http.routers.static.rule: "PathPrefix(`/static`) || PathPrefix(`/media`)"
depends_on:
- web


postgres:
image: postgres:9.6
environment:
Expand Down
Loading

0 comments on commit e63eed5

Please sign in to comment.