diff options
author | Alexandre Leray <alexandre@alexandreleray.com> | 2010-11-04 10:55:08 (GMT) |
---|---|---|
committer | Alexandre Leray <alexandre@alexandreleray.com> | 2010-11-04 10:55:08 (GMT) |
commit | 084fb8b277e375da5d03efeb55f050b701320db2 (patch) | |
tree | 7380a993c8ffd5590bce5d0a4ecac1e1581ed4c6 | |
parent | 8d5e7e9e34d5d533c384cb8622b77ec10c667fb2 (diff) |
display clone/synchronize according if repo already exists or not
-rwxr-xr-x | brainch/templates/brainch/view.html | 2 | ||||
-rwxr-xr-x | brainch/views/repositories/view.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/brainch/templates/brainch/view.html b/brainch/templates/brainch/view.html index c44e398..4ef4c20 100755 --- a/brainch/templates/brainch/view.html +++ b/brainch/templates/brainch/view.html @@ -17,7 +17,7 @@ <li><a href="{% url brainch-edit repo.user repo.slug %}">Edit the text</a></li> <li><a href="{% url brainch-pull-request repo.user repo.slug %}" style='text-decoration: line-through'>Propose your changes</a></li> {% else %} - {% if true %} + {% if clone %} <li><a href="{% url brainch-pull repo.user repo.slug %}">Synchronize your text</a></li> {% else %} <li><a href="{% url brainch-clone repo.user repo.slug %}">Clone this text</a></li> diff --git a/brainch/views/repositories/view.py b/brainch/views/repositories/view.py index e8e0a63..8c0eb66 100755 --- a/brainch/views/repositories/view.py +++ b/brainch/views/repositories/view.py @@ -41,10 +41,19 @@ def view(request, username, name): raise Http404 content = tree["CONTENT"].data + # if user is not the author + if request.user.username != username: + try: + Repository.objects.get(name=repo,user__username=request.user.username) + clone = True + except: + clone = False + ctx = { "repo": repo, "content": content, "revision": revision, + "clone": clone, } return render_to_response("brainch/view.html", ctx, \ context_instance=RequestContext(request)) |