From 1e9f713cee0f9bd618adda2ac8c31f1161af3de2 Mon Sep 17 00:00:00 2001
From: tenstormavi <avi.avinash3008@gmail.com>
Date: Oct 21 2016 09:23:01 +0000
Subject: [PATCH 1/2] Fixes : Fork button still visible after fork. Issue #1225.


---

diff --git a/.gitignore b/.gitignore
index 0b837d0..9c73ef3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@ docs/
 requests/
 releases/
 remotes/
-
+pagure_env/
 # Other python/editor specific files to ignore
 dist/
 build/
diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html
index 95abc8c..489f2e5 100644
--- a/pagure/templates/repo_master.html
+++ b/pagure/templates/repo_master.html
@@ -43,9 +43,15 @@
                 namespace=repo.namespace) }}">
               {{ forkbuttonform.csrf_token }}
             </form>
-            <button class="btn btn-sm btn-secondary"
+            {% if repo and repo.forks %}
+              <button class="btn btn-sm btn-secondary"
               onclick="$('#fork_project').submit();">
-              <span class="oi" data-glyph="fork"></span> Fork</button>
+              <span class="oi" data-glyph="fork"></span>View Fork</button>
+            {% else %}
+              <button class="btn btn-sm btn-secondary"
+              onclick="$('#fork_project').submit();">
+              <span class="oi" data-glyph="fork"></span>Fork</button>
+            {% endif %}
           {% endif %}
             <button title="{%-
             if is_watching(
diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py
index 0d6f07b..732c0e4 100644
--- a/pagure/ui/fork.py
+++ b/pagure/ui/fork.py
@@ -923,7 +923,6 @@ def fork_project(repo, username=None, namespace=None):
     if pagure.lib.get_project(
             SESSION, repo.name, user=flask.g.fas_user.username,
             namespace=namespace):
-        flask.flash('You had already forked this project')
         return flask.redirect(flask.url_for(
             'view_repo', repo=repo.name, username=flask.g.fas_user.username,
             namespace=namespace))

From 70debd1ef9f24784f084c88b3af4eff2f380067f Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Oct 21 2016 09:23:01 +0000
Subject: [PATCH 2/2] Change `Fork` button to `View Fork` on all pages of the project


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

---

diff --git a/pagure/__init__.py b/pagure/__init__.py
index 16f57fb..8badd64 100644
--- a/pagure/__init__.py
+++ b/pagure/__init__.py
@@ -405,6 +405,10 @@ def set_variables():
     if repo:
         flask.g.repo = pagure.lib.get_project(
             SESSION, repo, user=username, namespace=namespace)
+        if authenticated():
+            flask.g.repo_forked = pagure.lib.get_project(
+                SESSION, repo, user=flask.g.fas_user.username,
+                namespace=namespace)
 
         if not flask.g.repo \
             and APP.config.get('OLD_VIEW_COMMIT_ENABLED', False) \
diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html
index 489f2e5..02f6a16 100644
--- a/pagure/templates/repo_master.html
+++ b/pagure/templates/repo_master.html
@@ -35,6 +35,16 @@
           {% endif %}
           <div class="btn-group">
           {% if not repo.is_fork %}
+            {% if g.repo_forked %}
+              <a href="{{ url_for(
+                '.view_repo',
+                repo=repo.name,
+                username=g.fas_user.username,
+                namespace=repo.namespace) }}" class="btn btn-sm btn-secondary">
+
+              <span class="oi" data-glyph="fork"></span> View Fork
+              </a>
+            {% else %}
             <form method="POST" name="fork_project" id="fork_project"
               action="{{ url_for(
                 '.fork_project',
@@ -43,11 +53,6 @@
                 namespace=repo.namespace) }}">
               {{ forkbuttonform.csrf_token }}
             </form>
-            {% if repo and repo.forks %}
-              <button class="btn btn-sm btn-secondary"
-              onclick="$('#fork_project').submit();">
-              <span class="oi" data-glyph="fork"></span>View Fork</button>
-            {% else %}
               <button class="btn btn-sm btn-secondary"
               onclick="$('#fork_project').submit();">
               <span class="oi" data-glyph="fork"></span>Fork</button>

