Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
elastic-git>=0.3.3
unicore.content
unicore.google
unicore.distribute
pyramid
pyramid_jinja2
pyramid_celery
pyramid_celery>=2.0.0rc4
pyyaml
waitress
python-dateutil
Expand Down
1 change: 1 addition & 0 deletions springboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ def includeme(config):
config.add_route('category', '/category/{uuid}/')
config.add_route('page', '/page/{uuid}/')
config.add_route('flat_page', '/{slug}/')
config.add_route('api_notify', '/api/notify/', request_method='POST')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it our api's stuff that we currently have in unicore-cms haven't been ported yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hasn't, but I want to home it in the unicore.distribute package as a standalone capable thing.

config.scan(".views")
15 changes: 15 additions & 0 deletions springboard/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from pyramid import testing

import mock


class TestViews(SpringboardTestCase):

Expand Down Expand Up @@ -55,3 +57,16 @@ def test_flatpage(self):
self.mk_request(matchdict={'slug': page.slug}))
context = views.flat_page()
self.assertEqual(context['page'].uuid, page.uuid)

@mock.patch('unicore.distribute.tasks.fastforward.delay')
def test_api_notify(self, mock_delay):
request = self.mk_request()
request.method = 'POST'

views = SpringboardViews(request)
response = views.api_notify()
mock_delay.assert_called_once()
(working_dir, index_prefix), _ = mock_delay.call_args_list[0]
self.assertEqual(response, {})
self.assertEqual(working_dir, self.workspace.working_dir)
self.assertEqual(index_prefix, self.workspace.index_prefix)
7 changes: 7 additions & 0 deletions springboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from springboard.utils import parse_repo_name

from unicore.content.models import Category, Page
from unicore.distribute.tasks import fastforward

from slugify import slugify

Expand Down Expand Up @@ -64,3 +65,9 @@ def flat_page(self):
slug = self.request.matchdict['slug']
[page] = self.all_pages.filter(language=self.language, slug=slug)
return self.context(page=page)

@view_config(route_name='api_notify', renderer='json')
def api_notify(self):
fastforward.delay(self.workspace.working_dir,
self.workspace.index_prefix)
return {}