Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused or rarely used features #221

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3e20297
chore(refactor): Eliminate cove_ocds.lib package. first_render is not…
jpmckinney Oct 19, 2024
93b3440
build: Upgrade libcoveocds
jpmckinney Oct 19, 2024
59e1d60
feat: Remove OCDS Show
jpmckinney Oct 19, 2024
eb21e2e
feat: Remove release and record tables
jpmckinney Oct 19, 2024
48bc988
feat: Remove Key Field Information
jpmckinney Oct 19, 2024
8c3a343
chore(content): Remove "More Information" and "User Tracking" blocks
jpmckinney Oct 19, 2024
054da03
feat: Remove conversion to CSV and Excel
jpmckinney Oct 19, 2024
e058861
Merge branch 'main' into no-ocds-show
jpmckinney Oct 19, 2024
a3369bf
feat: Remove version switching. Always check against the latest versi…
jpmckinney Oct 19, 2024
fc09c99
chore: Add bootstrap files directly
jpmckinney Oct 20, 2024
f54a46f
chore: Add font files directly
jpmckinney Oct 20, 2024
90e5bde
feat: Merge the used parts of lib-cove-web with some refactoring
jpmckinney Oct 20, 2024
af76d4b
fix: Make source_url required (regression from making it blank but no…
jpmckinney Oct 20, 2024
da62f32
fix: Don't show publisher name if name not present
jpmckinney Oct 20, 2024
9ad2e16
feat: Remove unneeded model fields and methods
jpmckinney Oct 20, 2024
b7638f5
test: Remove footer tests
jpmckinney Oct 20, 2024
87566e0
fix: Don't delete the same files repetitively and forever
jpmckinney Oct 20, 2024
d915fb4
build: Add werkzeug
jpmckinney Oct 20, 2024
8b2423b
docs: Add Security comments (SSRF)
jpmckinney Oct 20, 2024
8c8da15
build: Add requests. Add migration.
jpmckinney Oct 21, 2024
41a1f4f
build: Upgrade ocdsextensionregistry
jpmckinney Oct 21, 2024
f884750
fix: Fix conditions for tabular files. Remove unnecessary filters, al…
jpmckinney Oct 21, 2024
845bbe8
i18n: Run python manage.py makemessages -a
jpmckinney Oct 21, 2024
39e0abd
i18n: Fix translated strings that are partial sentences, and fix subs…
jpmckinney Oct 21, 2024
46ced91
i18n: Remove deleted translations
jpmckinney Oct 21, 2024
264a2d4
chore: Fix blocktrans syntax from previous commits
jpmckinney Oct 21, 2024
693a573
i18n: Fix translated strings that are broken sentences
jpmckinney Oct 21, 2024
d350416
chore: Skip sorting keys
jpmckinney Oct 26, 2024
6cbfacd
chore: Make modal sample size easier to configure
jpmckinney Oct 26, 2024
f05d9d3
chore: common_error_types is always empty for OCDS
jpmckinney Oct 26, 2024
19364e2
chore: Remove curly quotes
jpmckinney Oct 26, 2024
be217ba
chore: Fix Docker lettercase warning
jpmckinney Nov 8, 2024
1e586b8
ci: Reuse workflow for automerge
jpmckinney Nov 25, 2024
c7d459e
ci: Reuse workflow for i18n
jpmckinney Nov 26, 2024
4b8bcd7
ci: Reuse workflow for docker
jpmckinney Nov 26, 2024
cbfca5c
ci: Reuse workflow for lint
jpmckinney Nov 26, 2024
6910617
Build
jpmckinney Nov 26, 2024
ae2dfb0
ci(lint): Add PAT
jpmckinney Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
# The pull_request_target workflow trigger is dangerous. Do not add unrelated logic to this workflow.
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
name: Auto-merge
on: pull_request_target
permissions:
pull-requests: write # to approve the PR
contents: write # to merge the PR
jobs:
dependabot:
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- id: dependabot-metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' || steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve ${{ github.event.pull_request.html_url }}
- if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' || steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
precommit:
if: ${{ github.event.pull_request.user.login == 'pre-commit-ci[bot]' }}
runs-on: ubuntu-latest
steps:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve ${{ github.event.pull_request.html_url }}
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash ${{ github.event.pull_request.html_url }}
automerge:
uses: open-contracting/.github/.github/workflows/automerge.yml@main
permissions:
pull-requests: write
contents: write
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
# Check requirements.txt contains production requirements.
- run: ./manage.py --help
- run: pip install -r requirements_dev.txt
# Compile messages, so that lib-cove-web translations are available.
- name: Install gettext
run: |
sudo apt update
Expand All @@ -26,7 +25,7 @@ jobs:
env:
PYTHONWARNINGS: error
shell: bash
# https://github.com/OpenDataServices/flatten-tool/pull/458
# https://github.com/OpenDataServices/flatten-tool/pull/458 > 0.20.0
# https://github.com/OpenDataServices/flatten-tool/issues/412
run: |
./manage.py migrate
Expand Down
30 changes: 1 addition & 29 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,4 @@ on:
- completed
jobs:
docker:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/docker/login-action#github-container-registry
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/setup-buildx-action#usage
- uses: docker/setup-buildx-action@v3
# https://github.com/docker/build-push-action#usage
- uses: docker/build-push-action@v6
with:
push: true
file: Dockerfile_django
tags: |
ghcr.io/${{ github.repository }}-django:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: docker/build-push-action@v6
with:
push: true
file: Dockerfile_static
tags: |
ghcr.io/${{ github.repository }}-static:latest
cache-from: type=gha
cache-to: type=gha,mode=max
uses: open-contracting/.github/.github/workflows/docker-django.yml@main
23 changes: 2 additions & 21 deletions .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,5 @@ on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- name: Install translate-toolkit
run: |
sudo apt update
sudo apt install gettext translate-toolkit
- run: pip install -r requirements.txt
- run: python manage.py makemessages -a
- name: Count incomplete translations
shell: bash
run: |
output=$(find . -name LC_MESSAGES -not -path "*/en/*" -exec pocount --incomplete --short "{}" +)
echo $output
[ "$output" = "" ]
i18n:
uses: open-contracting/.github/.github/workflows/i18n-django.yml@main
38 changes: 6 additions & 32 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
name: Lint
on: [push, pull_request]
env:
BASEDIR: https://raw.githubusercontent.com/open-contracting/standard-maintenance-scripts/main
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
env:
PAT: ${{ secrets.PAT }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || github.token }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- id: changed-files
uses: tj-actions/changed-files@v45
- uses: pre-commit/action@v3.0.1
continue-on-error: true
with:
extra_args: pip-compile --files ${{ steps.changed-files.outputs.all_changed_files }}
- if: ${{ env.PAT }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: '[github-actions] pre-commit autoupdate'
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/install.sh | bash -
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/script.sh | bash -
- run: pip install -r requirements_dev.txt
- run: pytest /tmp/test_requirements.py
lint:
uses: open-contracting/.github/.github/workflows/lint.yml@main
permissions:
contents: write
secrets:
personal-access-token: ${{ secrets.PAT }}
2 changes: 1 addition & 1 deletion Dockerfile_django
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11 as build-stage
FROM python:3.11 AS build-stage

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile_static
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11 as build-stage
FROM python:3.11 AS build-stage

COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
Expand All @@ -10,7 +10,7 @@ ENV DJANGO_ENV=production

RUN python manage.py collectstatic --noinput -v2

FROM nginxinc/nginx-unprivileged:latest as production-stage
FROM nginxinc/nginx-unprivileged:latest AS production-stage
USER root
COPY --from=build-stage --chown=nginx:root /workdir/static /usr/share/nginx/html/static
COPY --chown=nginx:root default.conf /etc/nginx/conf.d/default.conf
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

The DRT is a web application that allows you to review Open Contracting data, validate it against the Open Contracting Data Standard, and review it for errors or places for improvement. You can also use it to convert data between JSON and Excel spreadsheet formats.
The DRT is a web application that allows you to review Open Contracting data, validate it against the Open Contracting Data Standard, and review it for errors or places for improvement.

Docs about running locally etc. at https://ocds-data-review-tool.readthedocs.io/en/latest/
5 changes: 2 additions & 3 deletions core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
def from_settings(_request):
return {
"fathom": settings.FATHOM,
"hotjar": settings.HOTJAR,
"releases_or_records_table_length": settings.RELEASES_OR_RECORDS_TABLE_LENGTH,
"releases_or_records_table_slice": f":{settings.RELEASES_OR_RECORDS_TABLE_LENGTH}",
"support_email": settings.SUPPORT_EMAIL,
"delete_files_after_days": settings.DELETE_FILES_AFTER_DAYS,
}
31 changes: 7 additions & 24 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"bootstrap3",
"cove",
"cove.input",
"cove_ocds",
]

Expand All @@ -64,7 +62,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"cove.middleware.CoveConfigCurrentApp",
"cove_ocds.middleware.ExceptionMiddleware",
)

ROOT_URLCONF = "core.urls"
Expand All @@ -81,7 +79,6 @@
"django.template.context_processors.i18n",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"cove.context_processors.from_settings",
"core.context_processors.from_settings",
],
},
Expand Down Expand Up @@ -232,14 +229,6 @@
)

COVE_CONFIG = {
# lib-cove-web options
"app_name": "cove_ocds",
"app_base_template": "cove_ocds/base.html",
"app_verbose_name": "Open Contracting Data Review Tool",
"app_strapline": "Review your OCDS data.",
"input_methods": ["upload", "url", "text"],
"input_template": "cove_ocds/input.html",
"support_email": "data@open-contracting.org",
# SchemaOCDS options (add {lang} to the path)
"schema_version_choices": {
# version: (display, url, tag),
Expand All @@ -250,22 +239,16 @@
# Set default schema version to the latest version.
COVE_CONFIG["schema_version"] = list(COVE_CONFIG["schema_version_choices"])[-1]

DELETE_FILES_AFTER_DAYS = int(os.getenv("DELETE_FILES_AFTER_DAYS", "90")) # default 7
REQUESTS_TIMEOUT = int(os.getenv("REQUESTS_TIMEOUT", "10")) # default None
VALIDATION_ERROR_LOCATIONS_LENGTH = int(os.getenv("VALIDATION_ERROR_LOCATIONS_LENGTH", "100")) # default 1000


# Project configuration

FATHOM = {
"domain": os.getenv("FATHOM_ANALYTICS_DOMAIN") or "cdn.usefathom.com",
"id": os.getenv("FATHOM_ANALYTICS_ID"),
}

HOTJAR = {
"id": os.getenv("HOTJAR_ID", ""),
"sv": os.getenv("HOTJAR_SV", ""),
"date_info": os.getenv("HOTJAR_DATE_INFO", ""),
}

RELEASES_OR_RECORDS_TABLE_LENGTH = int(os.getenv("RELEASES_OR_RECORDS_TABLE_LENGTH", "25"))
DELETE_FILES_AFTER_DAYS = int(os.getenv("DELETE_FILES_AFTER_DAYS", "90"))
REQUESTS_TIMEOUT = int(os.getenv("REQUESTS_TIMEOUT", "10"))
SUPPORT_EMAIL = "data@open-contracting.org"
USER_AGENT = os.getenv(
"USER_AGENT", "DataReviewTool/1.0 (+https://review.standard.open-contracting.org; data@open-contracting.org)"
)
7 changes: 0 additions & 7 deletions core/templates/terms.html

This file was deleted.

14 changes: 7 additions & 7 deletions core/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from cove.urls import (
handler500, # noqa: F401
urlpatterns,
)
from django.conf import settings
from django.conf.urls.static import static
from django.urls import re_path
from django.urls import include, re_path

import cove_ocds.views

urlpatterns += [re_path(r"^data/(.+)$", cove_ocds.views.explore_ocds, name="explore")]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = [
re_path(r"^$", cove_ocds.views.data_input, name="index"),
re_path(r"^data/(.+)$", cove_ocds.views.explore_ocds, name="explore"),
re_path(r"^i18n/", include("django.conf.urls.i18n")),
*static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT),
]
14 changes: 14 additions & 0 deletions cove_ocds/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from http import HTTPStatus


class DataReviewToolError(Exception):
"""Base class for exceptions from within this module."""


class InputError(DataReviewToolError):
"""Raised if the input data is irretriavable or unprocessabe."""

def __init__(self, message="", heading="", status=HTTPStatus.OK):
self.message = message
self.heading = heading
self.status = status
23 changes: 23 additions & 0 deletions cove_ocds/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django import forms
from django.utils.translation import gettext_lazy as _

from cove_ocds import models


class UploadForm(forms.ModelForm):
class Meta:
model = models.SuppliedData
fields = ["original_file"]
labels = {"original_file": _("Upload a file (.json, .xlsx, .ods, .csv)")}


class UrlForm(forms.ModelForm):
source_url = forms.URLField(required=True, label=_("Supply a URL"))

class Meta:
model = models.SuppliedData
fields = ["source_url"]


class TextForm(forms.Form):
paste = forms.CharField(label=_("Paste (JSON only)"), widget=forms.Textarea)
Loading
Loading