Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into 51-update_logo
Browse files Browse the repository at this point in the history
  • Loading branch information
aguilerapy committed Nov 28, 2019
2 parents b19756d + dfc3343 commit 32c7916
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 118 deletions.
2 changes: 1 addition & 1 deletion default/data_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import uuid
from datetime import date
from zipfile import ZipFile, ZIP_DEFLATED
from zipfile import ZIP_DEFLATED, ZipFile

from django.conf import settings
from ocdskit.util import json_dumps, json_loads
Expand Down
2 changes: 1 addition & 1 deletion default/decorators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from dateutil import parser
from functools import wraps

from dateutil import parser
from django.http import JsonResponse

logger = logging.getLogger(__name__)
Expand Down
6 changes: 0 additions & 6 deletions default/static/css/ocdstoucanicons.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@
.ok-convert-to-spreadsheet:before {
content: "\e901";
}
.ok-data-review:before {
content: "\e902";
}
.ok-schema-spreadsheet:before {
content: "\e903";
}
.ok-extension-creator:before {
content: "\e904";
}
.ok-package-records:before {
content: "\e905";
}
Expand Down
31 changes: 24 additions & 7 deletions default/templates/default/compile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@
{% load i18n %}

{% block subtitle %} >> {% trans "Compile Releases" %} {% endblock %}

{% block info %}
<p>{% blocktrans %}Drag and drop one or more <a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">Release Packages</a> to generate a
<a href="https://standard.open-contracting.org/latest/en/schema/record_package/" target="_blank">Record Package</a> with Compiled Releases included.{% endblocktrans %}
{% blocktrans %}You can also click the <strong>Add a file</strong> link below.{% endblocktrans %}</p>
<p>{% blocktrans %}Use the <strong>Published Date</strong> option to set the Published Date in the output package.{% endblocktrans %}
{% blocktrans %}Check the <strong>Include Versioned Releases</strong> option if you want to add a Versioned Release to each Record. Read more about Compiled and Versioned releases in the
<a href="https://standard.open-contracting.org/latest/en/schema/merging/" target="_blank">OCDS documentation</a>.{% endblocktrans %}</p>
<p>{% blocktrans %}Please verify that your files are Release Packages before uploading.{% endblocktrans %}</p>
<p>
{% blocktrans trimmed %}
Drag and drop one or more
<a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">release packages</a>
to create a
<a href="https://standard.open-contracting.org/latest/en/schema/record_package/" target="_blank">record package</a>
with compiled releases included.
{% endblocktrans %}
{% trans "You can also click the <strong>Add a file</strong> link below." %}
</p>

<p>
{% trans "Fill in the <strong>Published date</strong> textbox to set <code>publishedDate</code> in the output package." %}
{% blocktrans trimmed %}
Check the <strong>Include Versioned Releases</strong> checkbox if you want to add a versioned release to each record.
Read more about compiled releases and versioned releases in the
<a href="https://standard.open-contracting.org/latest/en/schema/merging/" target="_blank">OCDS documentation</a>.
{% endblocktrans %}
</p>

<p>{% trans "Please verify that your files are release packages before uploading." %}</p>
{% endblock %}

{% block extraoptions %}
{% include "default/snippets/published_date.html" %}
<div class="checkbox">
Expand All @@ -19,6 +35,7 @@
</label>
</div>
{% endblock %}

{% block scripts %}
{{ block.super }}
<script type="text/javascript">
Expand Down
23 changes: 18 additions & 5 deletions default/templates/default/package-releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,29 @@
{% load i18n %}

{% block subtitle %} &gt;&gt; {% trans "Create Release Packages" %}{% endblock %}

{% block info %}
<p> {% blocktrans %}Drag and drop one or more <a href="https://standard.open-contracting.org/latest/en/getting_started/releases_and_records/#releases" target="_blank">Release</a> files
in the box below to create a <a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">Release Package</a> {% endblocktrans %}.
{% blocktrans %}You can also click the <strong>Add a file</strong> link below.{% endblocktrans %}
{% blocktrans %}Use the <strong>Published Date</strong> option to set the Published Date in the output package.{% endblocktrans %}</p>
<p>{% blocktrans %}The input files must be JSON files with a single Release each.{% endblocktrans%}</p>
<p>
{% blocktrans trimmed %}
Drag and drop one or more
<a href="https://standard.open-contracting.org/latest/en/getting_started/releases_and_records/#releases" target="_blank">releases</a>
to create a
<a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">release package</a>.
{% endblocktrans %}
{% trans "You can also click the <strong>Add a file</strong> link below." %}
</p>
<p>
{% trans "Fill in the <strong>Published date</strong> textbox to set <code>publishedDate</code> in the output package." %}
</p>
<p>
{% trans "Each input file must be a JSON file containing either one release or an array of releases." %}
</p>
{% endblock %}

{% block extraoptions %}
{% include "default/snippets/published_date.html" %}
{% endblock %}

{% block scripts %}
{{ block.super }}
{% include "default/snippets/published_date_scripts.html" %}
Expand Down
2 changes: 1 addition & 1 deletion default/templates/default/snippets/published_date.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
<div class="form-group pull-right">
<label for="publishedDate">{% blocktrans %}Published date: {% endblocktrans %}</label>
<label for="publishedDate">{% trans "Published date:" %}</label>
<input type="text" class="form-control" id="publishedDate"/>
</div>
12 changes: 9 additions & 3 deletions default/templates/default/upgrade.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
{% load i18n %}

{% block subtitle %} &gt;&gt; {% trans "Upgrade from 1.0 to 1.1" %} {% endblock %}

{% block info %}
<p>
{% blocktrans%}Drag and drop one of more OCDS <a href="https://standard.open-contracting.org/latest/en/getting_started/releases_and_records/#releases" target="_blank">Release</a> files or
<a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">Release</a>/<a href="https://standard.open-contracting.org/latest/en/schema/record_package/" target="_blank">Record</a> Package files to update them to OCDS 1.1.{% endblocktrans %}
{% blocktrans %}You can also click the <strong>Add a file</strong> link below to add files.{% endblocktrans %}
{% blocktrans trimmed %}
Drag and drop one or more
<a href="https://standard.open-contracting.org/latest/en/getting_started/releases_and_records/#releases" target="_blank">releases</a>,
<a href="https://standard.open-contracting.org/latest/en/schema/release_package/" target="_blank">release packages</a>, or
<a href="https://standard.open-contracting.org/latest/en/schema/record_package/" target="_blank">record packages</a>
to update them to OCDS 1.1.
{% endblocktrans %}
{% trans "You can also click the <strong>Add a file</strong> link below." %}
</p>
{% endblock %}
4 changes: 2 additions & 2 deletions default/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path, include
from django.urls import include, path

from . import views
from default import views

urlpatterns = [
path('', views.index, name='index'),
Expand Down
24 changes: 16 additions & 8 deletions default/views.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import os
import shutil
from zipfile import ZipFile, ZIP_DEFLATED
from zipfile import ZIP_DEFLATED, ZipFile

import flattentool
from django.http import FileResponse, JsonResponse, Http404
from django.http import FileResponse, Http404, JsonResponse
from django.shortcuts import render
from django.views.decorators.http import require_POST
from libcoveocds.config import LibCoveOCDSConfig
from ocdskit.combine import package_releases as package_releases_method, compile_release_packages
from ocdskit.combine import compile_release_packages
from ocdskit.combine import package_releases as package_releases_method
from ocdskit.upgrade import upgrade_10_11

from default.data_file import DataFile
from default.decorators import clear_files, published_date, require_files
from default.forms import MappingSheetOptionsForm
from default.mapping_sheet import (get_extended_mapping_sheet, get_mapping_sheet_from_uploaded_file,
get_mapping_sheet_from_url)
from ocdstoucan.settings import OCDS_TOUCAN_MAXFILESIZE, OCDS_TOUCAN_MAXNUMFILES
from .decorators import clear_files, require_files, published_date
from .forms import MappingSheetOptionsForm
from .data_file import DataFile
from .mapping_sheet import get_mapping_sheet_from_url, get_mapping_sheet_from_uploaded_file, get_extended_mapping_sheet


def retrieve_result(request, folder, id, format=None):
Expand Down Expand Up @@ -94,7 +96,13 @@ def perform_upgrade(request):
@require_files
@published_date
def perform_package_releases(request, published_date=''):
releases = [file.json() for file in _get_files_from_session(request)]
releases = []
for file in _get_files_from_session(request):
item = file.json()
if isinstance(item, list):
releases.extend(item)
else:
releases.append(item)

return _json_response({
'result.json': package_releases_method(releases, published_date=published_date),
Expand Down

0 comments on commit 32c7916

Please sign in to comment.