Permalink
Browse files

Merge branch 'feature/webui' into develop

Update unit tests and fix them

Conflicts:
	Bookie/bookie/tests/test_webviews/__init__.py
	Bookie/bookie/views/bmarks.py
	Bookie/bookie/views/tags.py
  • Loading branch information...
2 parents 5da78eb + 0b44cf5 commit a4d431b28178c21d5e850b39434d6415cd8d04f1 @mitechie committed Apr 4, 2011
View
@@ -47,11 +47,11 @@ def build_routes(config):
config.add_route("bmark_recent_page", "/recent/{page}",
view="bookie.views.bmarks.recent",
view_renderer="/bmark/recent.mako",)
- config.add_route("bmark_delete", "/bmark/delete/{bid}",
+ config.add_route("bmark_delete", "/bmark/delete",
view="bookie.views.bmarks.delete",)
- config.add_route("bmark_confirmdelete", "/bmark/confirm/delete/{bid}",
- view="bookie.views.bmarks.confirmdelete",
- view_renderer="/bmark/confirmdelete.mako",)
+ config.add_route("bmark_confirm_delete", "/bmark/confirm/delete/{bid}",
+ view="bookie.views.bmarks.confirm_delete",
+ view_renderer="/bmark/confirm_delete.mako",)
# tag related routes
@@ -78,22 +78,31 @@
}
.calendar {
- border: 2px solid #333;
-moz-border-radius: 5px;
border-radius: 5px;
margin: 0px .4em;
width: 4em;
}
.calendar h2 {
- background-color: red;
+ background-color:#F00;
+ background-image:-webkit-gradient( radial, 50% 50%, 0, 50% 50%, 40, from(#f44), to(#f00));
+ background-image:-moz-radial-gradient(circle, #f44, #f00);
+ background-image:radial-gradient(circle, #f44, #f00);
color: #FFF;
font-size: .9em;
font-weight: bold;
text-align: left;
padding: .1em .2em;
- border-bottom: 1px solid #999999;
+ border: 1px solid #333;
+ border-bottom-color:#999;
margin: 0px;
+ -webkit-border-top-right-radius: 2px;
+ -webkit-border-top-left-radius: 2px;
+ -moz-border-radius-topright: 2px;
+ -moz-border-radius-topleft: 2px;
+ border-top-right-radius: 2px;
+ border-top-left-radius: 2px;
}
.calendar div {
@@ -102,6 +111,14 @@
font-size: 1.3em;
text-align: center;
padding: .1em .2em;
+ border: 1px solid #333;
+ border-top:none;
+ -webkit-border-bottom-right-radius: 2px;
+ -webkit-border-bottom-left-radius: 2px;
+ -moz-border-radius-bottomright: 2px;
+ -moz-border-radius-bottomleft: 2px;
+ border-bottom-right-radius: 2px;
+ border-bottom-left-radius: 2px;
}
@@ -113,7 +130,7 @@
}
a.tag {
- padding: .2em;
+ padding: .2em .4em;
border: 1px solid #666666;
-moz-border-radius: 5px;
border-radius: 5px;
@@ -0,0 +1,13 @@
+<%inherit file="/main_wrap.mako" />
+<%def name="title()">Delete bookmark?</%def>
+
+
+<h2 style="text-align:center">Delete Confirmation</h2>
+<form method="post" action="${request.route_url('bmark_delete')}" style="text-align:center">
+ <p>Are you sure you want delete the following bookmark?</p>
+ <p><em>${bmark_description}</em></p>
+ <input type="hidden" id="bid" name="bid" value="${bid}" />
+ <!-- ew, onclick. This page will be replaced by a nice ajaxy delete confirmation, so it's ok. -->
+ <input id="cancel" type="button" value="Cancel" style="padding:2px;margin-right:40px" onclick="location.href='/'" />
+ <input id="delete" type="submit" value="Delete" style="padding:2px;" />
+</form>
@@ -1,7 +0,0 @@
-<%inherit file="/main_wrap.mako" />
-<%def name="title()">Delete bookmark?</%def>
-
-<h2>Really Delete?</h2>
-
-<a href="${request.route_url('bmark_delete', bid=bid)}">Yes</a> <a href="/">No</a>
-
@@ -42,7 +42,7 @@
<div class="yui3-u-1-8">
% if allow_edit:
<span><a href="#">edit</a></span>
- <span><a href="${request.route_url('bmark_confirmdelete', bid=bmark.bid)}">delete</a></span>
+ <span><a href="${request.route_url('bmark_confirm_delete', bid=bmark.bid)}">delete</a></span>
% endif
</div>
@@ -7,6 +7,7 @@
from nose.tools import ok_, eq_
from pyramid import testing
+from bookie.lib import access
from bookie.models import DBSession
from bookie.models import Bmark
from bookie.models import Tag
@@ -56,6 +57,7 @@ def test_bookmark_recent(self):
body_str = "Recent Bookmarks"
delete_str = "/bmark/confirm/delete"
+ access.edit_enabled = Mock(return_value=True)
res = self.testapp.get('/recent')
eq_(res.status, "200 OK",
@@ -78,13 +80,13 @@ def test_recent_page(self):
ok_(body_str in res.body,
msg="Page 1 should contain body_str: " + res.body)
- @patch('bookie.views.bmarks._is_authed')
- def test_allow_edit_requests(self, mocked_auth):
+ def test_allow_edit_requests(self):
"""Verify that if allow_edit is false we don't get edit/delete links"""
- mocked_auth.return_value = False
-
self._add_bmark()
delete_str = "/bmark/confirm/delete"
+
+ access.edit_enabled = Mock(return_value=False)
+
res = self.testapp.get('/recent')
# the delete link should not render if allow_edits is false
@@ -101,3 +103,36 @@ def test_delete_auth_failed(self):
eq_(res.status, "403 Forbidden",
msg='Import status is 403, ' + res.status)
+
+ def test_bookmark_tag(self):
+ """Verify we can call the /tags/bookmarks url """
+ self._add_bmark()
+
+ body_str = "Bookmarks: bookmarks"
+ delete_str = "/bmark/confirm/delete"
+
+ access.edit_enabled = Mock(return_value=True)
+ res = self.testapp.get('/tags/bookmarks')
+
+ eq_(res.status, "200 OK",
+ msg='recent status is 200, ' + res.status)
+ ok_(body_str in res.body,
+ msg="Request should contain body_str: " + res.body)
+
+ # there should be a delete link for the default bookie bookmark in the
+ # body as well
+ ok_(delete_str in res.body,
+ msg="Tag view delete link should be visible in the body:" + res.body)
+
+ def test_bookmark_tag_no_edits(self):
+ """Verify the tags view"""
+ self._add_bmark()
+
+ access.edit_enabled = Mock(return_value=False)
+
+ delete_str = "/bmark/confirm/delete"
+ res = self.testapp.get('/tags/bookmarks')
+
+ # The delete link should not render if allow_edits is false
+ ok_(delete_str not in res.body,
+ msg="Tag view delete link should NOT be visible:" + res.body)
@@ -5,7 +5,7 @@
from pyramid.httpexceptions import HTTPFound
from pyramid.httpexceptions import HTTPNotFound
-from bookie.lib.access import edit_enabled
+from bookie.lib import access
from bookie.models import DBSession
from bookie.models import Bmark
from bookie.models import BmarkMgr
@@ -30,24 +30,31 @@ def recent(request):
'max_count': RESULTS_MAX,
'count': len(recent_list),
'page': page,
- 'allow_edit': edit_enabled(request.registry.settings),
+ 'allow_edit': access.edit_enabled(request.registry.settings),
}
-def confirmdelete(request):
+def confirm_delete(request):
"""Confirm deletion of bookmark"""
rdict = request.matchdict
- bid = int(rdict.get('bid'))
+ bid = int(rdict.get('bid', 0))
+ if bid:
+ found = Bmark.query.get(bid)
+
+ if not found:
+ return HTTPNotFound()
+
return {
'bid': bid,
+ 'bmark_description': found.description
}
def delete(request):
"""Remove the bookmark in question"""
- rdict = request.matchdict
+ rdict = request.POST
- if not edit_enabled(request.registry.settings):
+ if not access.edit_enabled(request.registry.settings):
raise HTTPForbidden("Auth to edit is not enabled")
# make sure we have an id value
@@ -58,9 +65,6 @@ def delete(request):
if found:
DBSession.delete(found)
-
return HTTPFound(location=request.route_url('bmark_recent'))
- else:
- return HTTPNotFound()
- else:
- return HTTPNotFound()
+
+ return HTTPNotFound()
@@ -1,8 +1,9 @@
"""Controllers related to viewing Tag information"""
import logging
from pyramid.httpexceptions import HTTPNotFound
+from pyramid.settings import asbool
-from bookie.lib.access import edit_enabled
+from bookie.lib import access
from bookie.models import BmarkMgr
from bookie.models import TagMgr
@@ -44,5 +45,5 @@ def bmark_list(request):
'max_count': RESULTS_MAX,
'count': len(bmarks),
'page': page,
- 'allow_edit': edit_enabled(request.registry.settings),
+ 'allow_edit': access.edit_enabled(request.registry.settings),
}

0 comments on commit a4d431b

Please sign in to comment.