#3644 Add a link to the group when viewing a namespace
Merged 2 years ago by pingou. Opened 2 years ago by pingou.

file modified
+4
@@ -51,6 +51,10 @@ 

              "issue_tracker", True

          ) and not repo.settings.get("pull_requests", True):

              flask.abort(404, "No ticket trackers found for this project")

+         elif flask.request.method == "POST" \

+                 and repo.settings.get("issue_tracker_read_only", False) \

+                 and not repo.settings.get("pull_requests", True):

+             flask.abort(401, "The issue tracker for this project is read-only")

          return function(*args, **kwargs)

  

      return check_trackers

@@ -18,6 +18,16 @@ 

      {{ browse_header(select=select) }}

    </div>

  </div>

+   {% if namespace %}

+   <div class="container mt-5">

+     <p>

+       These projects are under the `{{ namespace }}` namespace making them

+       likely related to the <a href="{{ url_for('ui_ns.view_group', group=namespace)

+       }}">{{ namespace }}</a>

+       group.

+     </p>

+   </div>

+   {% endif %}

    <div class="container mt-5">

      {{ render_repos(

          repos, total_page, 'page', page,

file modified
+9 -2
@@ -58,8 +58,11 @@ 

  def index():

      """ Front page of the application.

      """

-     if authenticated() and flask.request.path == "/" \

-             and not flask.session.get("_requires_fpca", False):

+     if (

+         authenticated()

+         and flask.request.path == "/"

+         and not flask.session.get("_requires_fpca", False)

+     ):

          flask.request.from_index = True

          return flask.redirect(flask.url_for("ui_ns.userdash_projects"))

  
@@ -633,8 +636,12 @@ 

  

      total_page = int(ceil(projects_length / float(limit)))

  

+     if namespace in pagure_config["ALLOWED_PREFIX"]:

+         namespace = None

+ 

      return flask.render_template(

          "index.html",

+         namespace=namespace,

          repos=projects,

          repos_length=projects_length,

          total_page=total_page,

file modified
+1 -2
@@ -19,7 +19,6 @@ 

  import datetime

  import logging

  import os

- import re

  from collections import defaultdict, OrderedDict

  from math import ceil

  
@@ -33,7 +32,7 @@ 

  import pagure.exceptions

  import pagure.lib

  import pagure.lib.mimetype

- from pagure.decorators import has_issue_tracker, is_repo_admin, has_trackers

+ from pagure.decorators import has_issue_tracker, is_repo_admin

  

  import pagure.forms

  from pagure.config import config as pagure_config

file modified
+3 -2
@@ -23,6 +23,7 @@ 

  import json

  import logging

  import os

+ import re

  from math import ceil

  

  import flask
@@ -3222,7 +3223,7 @@ 

  @UI_NS.route("/fork/<username>/<namespace>/<repo>/droptag/", methods=["POST"])

  @login_required

  @is_repo_admin

- @has_issue_tracker

+ @has_trackers

  def remove_tag(repo, username=None, namespace=None):

      """ Remove the specified tag, associated with the issues, from the project.

      """
@@ -3275,7 +3276,7 @@ 

  )

  @login_required

  @is_repo_admin

- @has_issue_tracker

+ @has_trackers

  def edit_tag(repo, tag, username=None, namespace=None):

      """ Edit the specified tag associated with the issues of a project.

      """

@@ -149,34 +149,6 @@ 

                  '<p>The issue tracker for this project is read-only</p>',

                  output_text)

  

-     def test_edit_tag(self):

-         """ Test editing a ticket tag.

-         """

-         user = tests.FakeUser(username='pingou')

-         with tests.user_set(self.app.application, user):

-             output = self.app.post('/test/tag/tag1/edit', data={})

-             self.assertEqual(output.status_code, 401)

-             output_text = output.get_data(as_text=True)

-             self.assertIn(

-                 '<title>Unauthorized :\'( - Pagure</title>', output_text)

-             self.assertIn(

-                 '<p>The issue tracker for this project is read-only</p>',

-                 output_text)

- 

-     def test_drop_tags(self):

-         """ Test dropping a ticket tag.

-         """

-         user = tests.FakeUser(username='pingou')

-         with tests.user_set(self.app.application, user):

-             output = self.app.post('/test/droptag/', data={})

-             self.assertEqual(output.status_code, 401)

-             output_text = output.get_data(as_text=True)

-             self.assertIn(

-                 '<title>Unauthorized :\'( - Pagure</title>', output_text)

-             self.assertIn(

-                 '<p>The issue tracker for this project is read-only</p>',

-                 output_text)

- 

      def test_new_issue(self):

          """ Test creating a new ticket.

          """
@@ -351,5 +323,80 @@ 

              )

  

  

+ class PagureFlaskIssuesAndPRDisabledtests(tests.Modeltests):

+     """ Tests for flask issues controller of pagure with tickets and PRs

+     disabled.

+     """

+ 

+     @patch('pagure.lib.notify.send_email', MagicMock(return_value=True))

+     def setUp(self):

+         """ Set up the environnment, ran before every tests. """

+         super(PagureFlaskIssuesAndPRDisabledtests, self).setUp()

+ 

+         tests.create_projects(self.session)

+         tests.create_projects_git(os.path.join(self.path, 'repos'))

+ 

+         # Make the project's issue tracker read-only

+         repo = pagure.lib.get_authorized_project(self.session, 'test')

+         settings = repo.settings

+         settings['pull_requests'] = False

+         settings['issue_tracker_read_only'] = True

+         repo.settings = settings

+         self.session.add(repo)

+         self.session.commit()

+ 

+         # Create a couple of issue

+         msg = pagure.lib.new_issue(

+             session=self.session,

+             repo=repo,

+             title='Test issue #1',

+             content='We should work on this for the second time',

+             user='foo',

+             status='Open',

+             private=True,

+         )

+         self.session.commit()

+         self.assertEqual(msg.title, 'Test issue #1')

+ 

+         msg = pagure.lib.new_issue(

+             session=self.session,

+             repo=repo,

+             title='Test issue #2',

+             content='We should work on this for the second time',

+             user='foo',

+             status='Open',

+             private=False,

+         )

+         self.session.commit()

+         self.assertEqual(msg.title, 'Test issue #2')

+ 

+     def test_edit_tag(self):

+         """ Test editing a ticket tag.

+         """

+         user = tests.FakeUser(username='pingou')

+         with tests.user_set(self.app.application, user):

+             output = self.app.post('/test/tag/tag1/edit', data={})

+             self.assertEqual(output.status_code, 401)

+             output_text = output.get_data(as_text=True)

+             self.assertIn(

+                 '<title>Unauthorized :\'( - Pagure</title>', output_text)

+             self.assertIn(

+                 '<p>The issue tracker for this project is read-only</p>',

+                 output_text)

+ 

+     def test_drop_tags(self):

+         """ Test dropping a ticket tag.

+         """

+         user = tests.FakeUser(username='pingou')

+         with tests.user_set(self.app.application, user):

+             output = self.app.post('/test/droptag/', data={})

+             self.assertEqual(output.status_code, 401)

+             output_text = output.get_data(as_text=True)

+             self.assertIn(

+                 '<title>Unauthorized :\'( - Pagure</title>', output_text)

+             self.assertIn(

+                 '<p>The issue tracker for this project is read-only</p>',

+                 output_text)

+ 

  if __name__ == '__main__':

      unittest.main(verbosity=2)

When viewing projects of a namespace, it is nice to be able to access
quickly the group which is underneath this namespace (assuming there is
one, ie that the namespace isn't in the list of allowed_prefix).

Fixes https://pagure.io/pagure/issue/3582

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

@ryanlerch could you check this one? I think it can use some input from you :]

rebased onto a9e642fe9184d60f500ea375fa46dd02450a88f4

2 years ago

Really, without any changes? ?

Your test run is borked, so I dunno if this actually works...

rebased onto a7874ce21bcf43a16cb0cba5c929c8a7990782f1

2 years ago

Pretty please pagure-ci rebuild

rebased onto 48b2c53

2 years ago

1 new commit added

  • Fix tests
2 years ago

1 new commit added

  • Raise a 401 when trying to update a tag
2 years ago

Pull-Request has been merged by pingou

2 years ago