Skip to content

Add edit project button on project detail page #2823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2018
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
9 changes: 9 additions & 0 deletions tests/unit/packaging/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,12 @@ def test_multiple_licenses_from_classifiers(self, db_request):
result = views.release_detail(release, db_request)

assert result["license"] == "BSD License, MIT License"


class TestEditProjectButton:

def test_edit_project_button_returns_project(self):
project = pretend.stub()
assert views.edit_project_button(project, pretend.stub()) == {
'project': project
}
7 changes: 7 additions & 0 deletions tests/unit/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ def add_policy(name, filename):
traverse="/{username}",
domain=warehouse,
),
pretend.call(
"includes.edit-project-button",
"/_includes/edit-project-button/{project_name}",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{project_name}",
domain=warehouse,
),
pretend.call("search", "/search/", domain=warehouse),
pretend.call(
"accounts.profile",
Expand Down
10 changes: 10 additions & 0 deletions warehouse/packaging/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,13 @@ def release_detail(release, request):
"maintainers": maintainers,
"license": license,
}


@view_config(
route_name="includes.edit-project-button",
renderer="includes/edit-project-button.html",
uses_session=True,
permission="manage",
)
def edit_project_button(project, request):
return {'project': project}
7 changes: 7 additions & 0 deletions warehouse/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ def includeme(config):
traverse="/{username}",
domain=warehouse,
)
config.add_route(
"includes.edit-project-button",
"/_includes/edit-project-button/{project_name}",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{project_name}",
domain=warehouse,
)

# Search Routes
config.add_route("search", "/search/", domain=warehouse)
Expand Down
1 change: 0 additions & 1 deletion warehouse/static/sass/blocks/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
display: inline-block;
white-space: nowrap;
vertical-align: center;
overflow: hidden;

&:focus,
&:hover,
Expand Down
18 changes: 13 additions & 5 deletions warehouse/static/sass/blocks/_package-description.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@
*/

.package-description {
font-size: 1.1rem;
font-style: italic;
margin: 0;
padding: 0;
line-height: 42px;
min-height: 58px;
margin-top: -10px;

&__summary {
font-size: 1.1rem;
font-style: italic;
padding: 0;
margin-top: 10px;
}

&__edit-button {
margin-top: 10px;
}
}
17 changes: 17 additions & 0 deletions warehouse/templates/includes/edit-project-button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-#}

{% if request.user %}
<a href="{{ request.route_path('manage.project.settings', name=project.name) }}" class="button button--primary package-description__edit-button">Edit Project</a>
{% endif %}
13 changes: 6 additions & 7 deletions warehouse/templates/packaging/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,19 @@ <h1 class="package-header__name">
</div>
</section>

{% if release.summary %}{# TODO: https://github.com/pypa/warehouse/issues/2810 - add "or logged in user can edit package" #}
<section class="horizontal-section horizontal-section--grey horizontal-section--thin">
<div class="site-container">
<div class="split-layout split-layout--middle">
<div class="split-layout split-layout--middle package-description">
{% if release.summary %}
<p class="package-description">{{ release.summary }}</p>
<p class="package-description__summary">{{ release.summary }}</p>
{% else %}
<p class="package-description__summary">No project description provided.</p>
{% endif %}
{# TODO: https://github.com/pypa/warehouse/issues/2810 (if logged in user can edit package)
<a href="{{ request.route_path('manage.project.settings', name=project.normalized_name) }}" class="button button--primary">Edit Project</a>
#}
{% csi request.route_path("includes.edit-project-button", project_name=project.normalized_name) %}
{% endcsi %}
</div>
</div>
</section>
{% endif %}


<section>
Expand Down