Skip to content

Commit

Permalink
Merge pull request #133 from OpenUpSA/pippable
Browse files Browse the repository at this point in the history
Make indigo pip-installable
  • Loading branch information
longhotsummer committed Aug 2, 2018
2 parents 29b340c + ac74bfb commit b75ca9c
Show file tree
Hide file tree
Showing 36 changed files with 587 additions and 468 deletions.
5 changes: 0 additions & 5 deletions .buildpacks

This file was deleted.

3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -9,8 +9,7 @@ before_install:
- "rvm install ruby-2.3.3"
- "rvm use ruby-2.3.3"
install:
- "pip install -r requirements.txt"
- "pip install coveralls"
- "pip install .[test]"
- "bundle install"
- "npm install -g jshint"
script: coverage run manage.py test && jshint indigo_app/static/javascript/indigo/
Expand Down
1 change: 0 additions & 1 deletion Aptfile

This file was deleted.

4 changes: 0 additions & 4 deletions CHECKS

This file was deleted.

19 changes: 19 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,19 @@
include LICENSE
include README.md
include VERSION

recursive-include locale *
recursive-include indigo_api/fixtures *
recursive-include indigo_api/static *
recursive-include indigo_api/templates *

recursive-include indigo_app/static *
recursive-include indigo_app/templates *

recursive-include indigo_resolver/static *
recursive-include indigo_resolver/templates *

recursive-include indigo_pl/static *
recursive-include indigo_pl/templates *
recursive-include indigo_za/static *
recursive-include indigo_za/templates *
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
3.0.0
7 changes: 5 additions & 2 deletions indigo/analysis/toc/base.py
Expand Up @@ -13,6 +13,8 @@
_('Government Notice')
_('Part')
_('Section')
_('Preface')
_('Preamble')


@plugins.register('toc')
Expand Down Expand Up @@ -118,9 +120,10 @@ def make_toc_entry(self, element, component, parent=None):
# eg. schedule1 -> Schedule 1
m = self.component_id_re.match(component)
if m:
heading = ' '.join(m.groups()).capitalize()
typ, num = m.groups()
heading = '%s %s' % (_(typ.capitalize()), num)
else:
heading = component.capitalize()
heading = _(component.capitalize())
else:
try:
heading = _collect_string_content(element.heading)
Expand Down
46 changes: 0 additions & 46 deletions indigo/middleware.py

This file was deleted.

7 changes: 1 addition & 6 deletions indigo/settings.py
Expand Up @@ -60,7 +60,6 @@
'rest_framework.authtoken',
'rest_auth',
'django_filters',
'django_extensions',

# required by the Indigo API
'taggit',
Expand Down Expand Up @@ -185,7 +184,7 @@
# for each Django app

# where the compiled assets go
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_ROOT = 'staticfiles'
# the URL for assets
STATIC_URL = '/static/'

Expand Down Expand Up @@ -292,10 +291,6 @@
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000

GOOGLE_ANALYTICS_ID = os.environ.get('GOOGLE_ANALYTICS_ID')
# server-side google analytics
GOOGLE_ANALYTICS_INCLUDE_PATH = ['/api/']
if GOOGLE_ANALYTICS_ID and not DEBUG:
MIDDLEWARE += ('indigo.middleware.GoogleAnalyticsMiddleware',)

# disable email in development
if DEBUG:
Expand Down
2 changes: 1 addition & 1 deletion indigo_api/atom.py
Expand Up @@ -159,7 +159,7 @@ def render(self, data, media_type=None, renderer_context=None):
return feed.writeString('utf-8')

def add_item(self, feed, doc):
url = self.serializer.get_published_url(doc, with_date=True)
url = self.serializer.get_published_url(doc)
feed.add_item(
unique_id=url,
pubdate=doc.created_at,
Expand Down
1 change: 1 addition & 0 deletions indigo_api/fixtures/published.json
Expand Up @@ -61,6 +61,7 @@
"country": "za",
"created_at": "2015-01-15T09:20:02.710Z",
"updated_at": "2015-02-17T10:57:47.779Z",
"expression_date": "2001-10-01",
"deleted": false,
"frbr_uri": "/za/act/2001/8",
"work_id": 4
Expand Down
20 changes: 19 additions & 1 deletion indigo_api/fixtures/user.json
Expand Up @@ -67,7 +67,25 @@
["delete_document", "indigo_api", "document"]
],
"password": "pbkdf2_sha256$12000$NkxvaoXfb4p2$A6u0ez3trvm9VyIT606HB5G3NKRLl4znE4ZlsZS5T7U=",
"username": "non-publisher@example.com",
"date_joined": "2012-01-13 00:14:00+00:00"
}
},
{
"pk": 4,
"model": "auth.user",
"fields": {
"username": "api-user@example.com",
"first_name": "user that can read via the api",
"last_name": "",
"is_active": true,
"is_superuser": false,
"is_staff": false,
"last_login": "2012-01-13 00:14:00+00:00",
"groups": [],
"user_permissions": [
["view_published_document", "indigo_api", "document"]
],
"password": "pbkdf2_sha256$12000$NkxvaoXfb4p2$A6u0ez3trvm9VyIT606HB5G3NKRLl4znE4ZlsZS5T7U=",
"date_joined": "2012-01-13 00:14:00+00:00"
}
}
Expand Down
19 changes: 19 additions & 0 deletions indigo_api/migrations/0054_view_published_doc_perms.py
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-07-28 16:11
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('indigo_api', '0053_work_view_perm'),
]

operations = [
migrations.AlterModelOptions(
name='document',
options={'permissions': (('publish_document', 'Can publish and edit non-draft documents'), ('view_published_document', 'Can view publish documents through the API'))},
),
]
29 changes: 29 additions & 0 deletions indigo_api/migrations/0055_document_expression_dates.py
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-07-30 19:37
from __future__ import unicode_literals
import datetime

from django.db import migrations


def ensure_expression_dates(apps, schema_editor):
Work = apps.get_model("indigo_api", "Work")
Document = apps.get_model("indigo_api", "Document")
db_alias = schema_editor.connection.alias

default_date = datetime.date(1980, 1, 1)

for document in Document.objects.filter(expression_date=None).using(db_alias).all():
document.expression_date = document.work.publication_date or datetime
document.save()


class Migration(migrations.Migration):

dependencies = [
('indigo_api', '0054_view_published_doc_perms'),
]

operations = [
migrations.RunPython(ensure_expression_dates, migrations.RunPython.noop),
]
20 changes: 20 additions & 0 deletions indigo_api/migrations/0056_doc_requires_expression_date.py
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-07-30 19:42
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('indigo_api', '0055_document_expression_dates'),
]

operations = [
migrations.AlterField(
model_name='document',
name='expression_date',
field=models.DateField(help_text=b'Date of publication or latest amendment'),
),
]

0 comments on commit b75ca9c

Please sign in to comment.