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
119 changes: 0 additions & 119 deletions tests/unit/manage/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8443,125 +8443,6 @@ def test_raises_404_with_out_of_range_page(self, db_request):
assert views.manage_project_history(project, db_request)


class TestManageProjectJournal:
def test_get(self, db_request):
project = ProjectFactory.create()
older_journal = JournalEntryFactory.create(
name=project.name,
submitted_date=datetime.datetime(2017, 2, 5, 17, 18, 18, 462_634),
)
newer_journal = JournalEntryFactory.create(
name=project.name,
submitted_date=datetime.datetime(2018, 2, 5, 17, 18, 18, 462_634),
)

assert views.manage_project_journal(project, db_request) == {
"project": project,
"journals": [newer_journal, older_journal],
}

def test_raises_400_with_pagenum_type_str(self, monkeypatch, db_request):
params = MultiDict({"page": "abc"})
db_request.params = params

journals_query = pretend.stub()
db_request.journals_query = pretend.stub(
journals_query=lambda *a, **kw: journals_query
)

page_obj = pretend.stub(page_count=10, item_count=1000)
page_cls = pretend.call_recorder(lambda *a, **kw: page_obj)
monkeypatch.setattr(views, "SQLAlchemyORMPage", page_cls)

url_maker = pretend.stub()
url_maker_factory = pretend.call_recorder(lambda request: url_maker)
monkeypatch.setattr(views, "paginate_url_factory", url_maker_factory)

project = ProjectFactory.create()
with pytest.raises(HTTPBadRequest):
views.manage_project_journal(project, db_request)

assert page_cls.calls == []

def test_first_page(self, db_request):
page_number = 1
params = MultiDict({"page": page_number})
db_request.params = params

project = ProjectFactory.create()
items_per_page = 25
total_items = items_per_page + 2
for _ in range(total_items):
JournalEntryFactory.create(
name=project.name, submitted_date=datetime.datetime.now()
)
journals_query = (
db_request.db.query(JournalEntry)
.options(joinedload("submitted_by"))
.filter(JournalEntry.name == project.name)
.order_by(JournalEntry.submitted_date.desc(), JournalEntry.id.desc())
)

journals_page = SQLAlchemyORMPage(
journals_query,
page=page_number,
items_per_page=items_per_page,
item_count=total_items,
url_maker=paginate_url_factory(db_request),
)
assert views.manage_project_journal(project, db_request) == {
"project": project,
"journals": journals_page,
}

def test_last_page(self, db_request):
page_number = 2
params = MultiDict({"page": page_number})
db_request.params = params

project = ProjectFactory.create()
items_per_page = 25
total_items = items_per_page + 2
for _ in range(total_items):
JournalEntryFactory.create(
name=project.name, submitted_date=datetime.datetime.now()
)
journals_query = (
db_request.db.query(JournalEntry)
.options(joinedload("submitted_by"))
.filter(JournalEntry.name == project.name)
.order_by(JournalEntry.submitted_date.desc(), JournalEntry.id.desc())
)

journals_page = SQLAlchemyORMPage(
journals_query,
page=page_number,
items_per_page=items_per_page,
item_count=total_items,
url_maker=paginate_url_factory(db_request),
)
assert views.manage_project_journal(project, db_request) == {
"project": project,
"journals": journals_page,
}

def test_raises_404_with_out_of_range_page(self, db_request):
page_number = 3
params = MultiDict({"page": page_number})
db_request.params = params

project = ProjectFactory.create()
items_per_page = 25
total_items = items_per_page + 2
for _ in range(total_items):
JournalEntryFactory.create(
name=project.name, submitted_date=datetime.datetime.now()
)

with pytest.raises(HTTPNotFound):
assert views.manage_project_journal(project, db_request)


class TestManageOIDCProviderViews:
def test_initializes(self):
metrics = pretend.stub()
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,6 @@ def add_policy(name, filename):
traverse="/{project_name}",
domain=warehouse,
),
pretend.call(
"manage.project.journal",
"/manage/project/{project_name}/journal/",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{project_name}",
domain=warehouse,
),
pretend.call(
"packaging.project",
"/project/{name}/",
Expand Down
59 changes: 3 additions & 56 deletions warehouse/locale/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ msgid "Teams"
msgstr ""

#: warehouse/templates/includes/manage/manage-organization-menu.html:37
#: warehouse/templates/includes/manage/manage-project-menu.html:59
#: warehouse/templates/includes/manage/manage-project-menu.html:53
#: warehouse/templates/includes/manage/manage-team-menu.html:31
msgid "Settings"
msgstr ""
Expand All @@ -2457,16 +2457,12 @@ msgstr ""
msgid "Security history"
msgstr ""

#: warehouse/templates/includes/manage/manage-project-menu.html:37
msgid "Journal"
msgstr ""

#: warehouse/templates/includes/manage/manage-project-menu.html:44
#: warehouse/templates/includes/manage/manage-project-menu.html:38
#: warehouse/templates/manage/project/documentation.html:21
msgid "Documentation"
msgstr ""

#: warehouse/templates/includes/manage/manage-project-menu.html:52
#: warehouse/templates/includes/manage/manage-project-menu.html:46
msgid "Publishing"
msgstr ""

Expand Down Expand Up @@ -4114,8 +4110,6 @@ msgstr ""

#: warehouse/templates/manage/organization/roles.html:59
#: warehouse/templates/manage/organization/roles.html:190
#: warehouse/templates/manage/project/journal.html:37
#: warehouse/templates/manage/project/journal.html:52
#: warehouse/templates/manage/project/roles.html:374
#: warehouse/templates/manage/team/roles.html:43
#: warehouse/templates/manage/team/roles.html:94
Expand Down Expand Up @@ -4447,53 +4441,6 @@ msgstr ""
msgid "Security history for %(project_name)s"
msgstr ""

#: warehouse/templates/manage/project/journal.html:20
#, python-format
msgid "'%(project_name)s' project journal"
msgstr ""

#: warehouse/templates/manage/project/journal.html:23
msgid "Project journal"
msgstr ""

#: warehouse/templates/manage/project/journal.html:25
msgid ""
"Each time you or your collaborators update this project, the action is "
"recorded and displayed here."
msgstr ""

#: warehouse/templates/manage/project/journal.html:28
#, python-format
msgid ""
"This feature will be deprecated in the future, replaced by the <a "
"href=\"%(href)s\">security history page</a>."
msgstr ""

#: warehouse/templates/manage/project/journal.html:32
#, python-format
msgid "History for %(project_name)s"
msgstr ""

#: warehouse/templates/manage/project/journal.html:35
#: warehouse/templates/manage/project/journal.html:44
msgid "Action"
msgstr ""

#: warehouse/templates/manage/project/journal.html:36
#: warehouse/templates/manage/project/journal.html:48
msgid "Date"
msgstr ""

#: warehouse/templates/manage/project/journal.html:45
#, python-format
msgid "Release %(version)s:"
msgstr ""

#: warehouse/templates/manage/project/journal.html:54
#, python-format
msgid "from %(ip_address)s"
msgstr ""

#: warehouse/templates/manage/project/manage_project_base.html:20
#, python-format
msgid "Manage '%(project_name)s'"
Expand Down
34 changes: 0 additions & 34 deletions warehouse/manage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4502,40 +4502,6 @@ def manage_project_history(project, request):
return {"project": project, "events": events}


@view_config(
route_name="manage.project.journal",
context=Project,
renderer="manage/project/journal.html",
uses_session=True,
permission="manage:project",
has_translations=True,
)
def manage_project_journal(project, request):
try:
page_num = int(request.params.get("page", 1))
except ValueError:
raise HTTPBadRequest("'page' must be an integer.")

journals_query = (
request.db.query(JournalEntry)
.options(joinedload("submitted_by"))
.filter(JournalEntry.name == project.name)
.order_by(JournalEntry.submitted_date.desc(), JournalEntry.id.desc())
)

journals = SQLAlchemyORMPage(
journals_query,
page=page_num,
items_per_page=25,
url_maker=paginate_url_factory(request),
)

if journals.page_count and page_num > journals.page_count:
raise HTTPNotFound

return {"project": project, "journals": journals}


@view_config(
route_name="manage.project.documentation",
context=Project,
Expand Down
7 changes: 0 additions & 7 deletions warehouse/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,6 @@ def includeme(config):
traverse="/{project_name}",
domain=warehouse,
)
config.add_route(
"manage.project.journal",
"/manage/project/{project_name}/journal/",
factory="warehouse.packaging.models:ProjectFactory",
traverse="/{project_name}",
domain=warehouse,
)

# Packaging
config.add_redirect("/p/{name}/", "/project/{name}/", domain=warehouse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
{% trans %}Security history{% endtrans %}
</a>
</li>
<li>
<a href="{{ request.route_path('manage.project.journal', project_name=project.normalized_name)}}" class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'journal' %}vertical-tabs__tab--is-active{% endif %} {% if mode == 'mobile' %}vertical-tabs__tab--mobile{% endif %}" {% if active_tab == 'journal' %}aria-selected="true"{% endif %}>
<i class="fa fa-history" aria-hidden="true"></i>
{% trans %}Journal{% endtrans %}
</a>
</li>
{% if project.has_docs %}
<li>
<a href="{{ request.route_path('manage.project.documentation', project_name=project.normalized_name)}}" class="vertical-tabs__tab vertical-tabs__tab--with-icon {% if active_tab == 'documentation' %}vertical-tabs__tab--is-active{% endif %} {% if mode == 'mobile' %}vertical-tabs__tab--mobile{% endif %}" {% if active_tab == 'documentation' %}aria-selected="true"{% endif %}>
Expand Down
61 changes: 0 additions & 61 deletions warehouse/templates/manage/project/journal.html

This file was deleted.