#4594 templates/repo_pull_request: fix view when the source project was deleted
Merged 4 years ago by pingou. Opened 4 years ago by jlanda.
jlanda/pagure fix-pr-deleted-fork  into  master

@@ -84,7 +84,7 @@ 

          </div>

          <div class="mt-2">

            <small>

-             {% if pull_request.remote_git or pull_request.project_from.is_fork %}

+             {% if pull_request.remote_git or (pull_request.project_from and pull_request.project_from.is_fork) %}

              <span class="badge badge-light badge-pill border border-secondary font-1em">

                {% if pull_request.remote_git %}

                  <i class="fa fa-globe"></i>
@@ -99,8 +99,7 @@ 

                  {%- endif -%}

                  {{pull_request.project_from.name}}

                {% endif %}

-               </span>

-             {% endif %}

+             </span>

              <a href="{{ url_for('ui_ns.view_tree',

                      repo=pull_request.project_from.name,

                      username=pull_request.project_from.user.user
@@ -111,7 +110,13 @@ 

                    class="badge badge-secondary badge-pill border border-secondary font-1em">

                  <span class="fa fa-random"></span>

                  {{ pull_request.branch_from }}

-               </a>

+             </a>

+             {% else %}

+             <span class="badge badge-light badge-pill border border-seconday font-1em">

+               <i class="fa fa-question"></i>

+               Unknown source

+             </span>

+             {% endif %}

            &nbsp;into&nbsp;

              <a href="{{ url_for('ui_ns.view_tree',

                        repo=pull_request.project.name,
@@ -292,7 +297,7 @@ 

      <div class="list-group">

          {% for commit in diff_commits %}

  

-             {% if pull_request.status and pull_request.project_from.is_fork %}

+             {% if pull_request.status and (pull_request.project_from and pull_request.project_from.is_fork) %}

                {% set commit_link = url_for(

                  'ui_ns.view_commit',

                  repo=pull_request.project_from.name,

file modified
+1
@@ -331,6 +331,7 @@ 

      can_delete_branch = (

          pagure_config.get("ALLOW_DELETE_BRANCH", True)

          and not request.remote_git

+         and request.project_from

          and pagure.utils.is_repo_committer(request.project_from)

      )

      return flask.render_template(

@@ -205,7 +205,9 @@ 

          user = tests.FakeUser(username="pingou")

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

              data = {"csrf_token": self.get_csrf()}

- 

+             # Check the PR view on UI

+             output = self.app.get("/test/pull-request/1")

+             self.assertEqual(output.status_code, 200)

              # Merge PR

              output = self.app.post(

                  "/test/pull-request/1/merge", data=data, follow_redirects=True

rebased onto 2791b3ebf82946b746ed383689709dcc3b6bb111

4 years ago

Let's add a couple of () ie: pull_request.remote_git or (pull_request.project_from and pull_request.project_from.is_fork) I find it makes things clearer :)

Two comments, then let's get this in :)

rebased onto 38a4ae1

4 years ago

Pull-Request has been merged by pingou

4 years ago