Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
490 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from h import hashids | ||
|
||
|
||
def url_for_group(request, group): | ||
"""Return the URL for the given group's page.""" | ||
hashid = hashids.encode(request, "h.groups", number=group.id) | ||
return request.route_url('group_read', hashid=hashid, slug=group.slug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends "h:templates/layouts/base.html.jinja2" %} | ||
|
||
{% block page_title %}{{ group.name }}{% endblock page_title %} | ||
|
||
{% block styles %} | ||
{% assets "app_css" %} | ||
<link rel="stylesheet" href="{{ ASSET_URL }}"> | ||
{% endassets %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="content paper"> | ||
{% include "h:templates/includes/header.html.jinja2" %} | ||
This is group {{ group.name }}. | ||
<form method="POST"> | ||
<button type="submit"> | ||
Join this group | ||
</button> | ||
</form> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends "h:templates/layouts/base.html.jinja2" %} | ||
|
||
{% block page_title %}{{ group.name }}{% endblock page_title %} | ||
|
||
{% block styles %} | ||
{% assets "app_css" %} | ||
<link rel="stylesheet" href="{{ ASSET_URL }}"> | ||
{% endassets %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="content paper"> | ||
{% include "h:templates/includes/header.html.jinja2" %} | ||
This is group {{ group.name }}. | ||
<a href="{{ request.route_url('login') }}" target="_blank"> | ||
Login to join this group. | ||
</a> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import mock | ||
|
||
from h.groups import logic | ||
|
||
|
||
@mock.patch('h.groups.logic.hashids') | ||
def test_url_for_group_encodes_groupid(hashids): | ||
"""It should encode the groupid to get the hashid. | ||
And then pass the hashid to route_url(). | ||
""" | ||
hashids.encode.return_value = mock.sentinel.hashid | ||
request = mock.Mock() | ||
group = mock.Mock() | ||
|
||
logic.url_for_group(request, group) | ||
|
||
assert hashids.encode.call_args[1]['number'] == group.id | ||
assert request.route_url.call_args[1]['hashid'] == mock.sentinel.hashid | ||
|
||
|
||
@mock.patch('h.groups.logic.hashids') | ||
def test_url_for_group_returns_url(_): | ||
"""It should return the URL from request.route_url().""" | ||
request = mock.Mock() | ||
request.route_url.return_value = mock.sentinel.group_url | ||
|
||
url = logic.url_for_group(request, mock.Mock()) | ||
|
||
assert url == mock.sentinel.group_url |
Oops, something went wrong.