Commits

Matthew Marshall committed 48897f8

Added page for editing repository information.

Comments (0)

Files changed (16)

hgtemplates/freehg/changelog.tmpl

             <h2><a href="{url}">#repo|escape#</a> / changelog</h2>
         </div>
         <div class="page_nav">
-            <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog/#rev#{sessionvars%urlparameter}">shortlog</a> | changelog | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a>#archives%archiveentry#
+            <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog/#rev#{sessionvars%urlparameter}">shortlog</a> | changelog | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a>#archives%archiveentry#
             <br/>
             #changenav%naventry#<br/>
         </div>

hgtemplates/freehg/changeset.tmpl

             <h2><a href="{url}">#repo|escape#</a> / changeset</h2>
         </div>
         <div class="page_nav">
-        <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog/#rev#{sessionvars%urlparameter}">shortlog</a> | <a href="{url}log/#rev#{sessionvars%urlparameter}">changelog</a> | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a> | changeset | <a href="{url}raw-rev/#node|short#">raw</a> #archives%archiveentry#<br/>
+        <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog/#rev#{sessionvars%urlparameter}">shortlog</a> | <a href="{url}log/#rev#{sessionvars%urlparameter}">changelog</a> | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a> | changeset | <a href="{url}raw-rev/#node|short#">raw</a> #archives%archiveentry#<br/>
         </div>
 
         <div>

hgtemplates/freehg/error.tmpl

         </div>
 
         <div class="page_nav">
-            <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> | <a href="{url}log{sessionvars%urlparameter}">changelog</a> | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a><br/>
+            <a href="{url}{sessionvars%urlparameter}">summary</a> | <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> | <a href="{url}log{sessionvars%urlparameter}">changelog</a> | <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a><br/>
         </div>
 
         <div class="page_body">

hgtemplates/freehg/fileannotate.tmpl

         <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
         <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
         <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
-        <a href="{url}file/#node|short##path|urlescape#{sessionvars%urlparameter}">manifest</a> |
+        <a href="{url}file/#node|short##path|urlescape#{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a> |
         <a href="{url}rev/#node|short#{sessionvars%urlparameter}">changeset</a> |
         <a href="{url}file/{node|short}/#file|urlescape#{sessionvars%urlparameter}">file</a> |
         <a href="{url}log/{node|short}/#file|urlescape#{sessionvars%urlparameter}">revisions</a> |

hgtemplates/freehg/filediff.tmpl

         <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
         <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
         <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
-        <a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">manifest</a> |
+        <a href="{url}file/{node|short}{path|urlescape}{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a> |
         <a href="{url}rev/{node|short}{sessionvars%urlparameter}">changeset</a> |
         <a href="{url}file/{node|short}/{file|urlescape}{sessionvars%urlparameter}">file</a> |
         <a href="{url}log/{node|short}/{file|urlescape}{sessionvars%urlparameter}">revisions</a> |

hgtemplates/freehg/filelog.tmpl

         <a href="{url}{sessionvars%urlparameter}">summary</a> |
         <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
         <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
-        <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
+        <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}edit/">edit</a> |
         <a href="{url}file/{node|short}/#file|urlescape#{sessionvars%urlparameter}">file</a> |
         revisions |
         <a href="{url}annotate/{node|short}/#file|urlescape#{sessionvars%urlparameter}">annotate</a> |

hgtemplates/freehg/filerevision.tmpl

         <a href="{url}{sessionvars%urlparameter}">summary</a> |
         <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
         <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
-        <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
+        <a href="{url}tags{sessionvars%urlparameter}">tags</a> | <a href="{url}edit/">edit</a> |
         <a href="{url}file/#node|short##path|urlescape#{sessionvars%urlparameter}">manifest</a> |
         <a href="{url}rev/#node|short#{sessionvars%urlparameter}">changeset</a> |
         file |

hgtemplates/freehg/manifest.tmpl

             <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
             <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
             <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
-            manifest |
+            manifest | <a href="{url}edit/">edit</a> |
             <a href="{url}rev/#node|short#{sessionvars%urlparameter}">changeset</a> #archives%archiveentry#<br/>
         </div>
 

hgtemplates/freehg/shortlog.tmpl

             shortlog |
             <a href="{url}log/#rev#{sessionvars%urlparameter}">changelog</a> |
             <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
-            <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a>#archives%archiveentry#
+            <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a>#archives%archiveentry# | <a href="{url}edit/">edit</a>
             <br/>
             #changenav%navshortentry#<br />
         </div>

hgtemplates/freehg/summary.tmpl

     <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
     <a href="{url}tags{sessionvars%urlparameter}">tags</a> |
     <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a>#archives%archiveentry#
-    <br/>
+     | <a href="{url}edit/">edit</a><br/>
 </div>
 
 <dl>

hgtemplates/freehg/tags.tmpl

             <a href="{url}shortlog{sessionvars%urlparameter}">shortlog</a> |
             <a href="{url}log{sessionvars%urlparameter}">changelog</a> |
             tags |
-            <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a>
+            <a href="{url}file/#node|short#{sessionvars%urlparameter}">manifest</a> | <a href="{url}edit/">edit</a>
             <br/>
         </div>
 
 RewriteRule ^(u/.+)$ hgfcgi/dispatch.fcgi/$1 [L]
 
 RewriteRule ^(u/\w+/\w+/?)$ dispatch.fcgi/$1 [L]
+RewriteRule ^(u/\w+/\w+/edit/?)$ dispatch.fcgi/$1 [L]
 
 RewriteRule ^(u/.+)$ hgfcgi/dispatch.fcgi/$1 [L]
 
             else:
                 return self.cleaned_data['username']
         return self.cleaned_data
+
+
+class EditRepoForm(forms.Form):
+    long_name = forms.CharField(max_length=50, required=False,
+            label=u"Aesthetic Name",
+            widget=forms.TextInput(attrs={'class': 'required text'}),
+            help_text=u"optional version of the name fit for human consumption")
+    description = forms.CharField(max_length=5000, required=False,
+            widget=forms.Textarea())
 from django.template import RequestContext
 from django.contrib.auth import login, authenticate
 from django.http import HttpResponseRedirect
+from django.contrib.auth.decorators import login_required
 
-from freehg.repos.forms import NewRepoForm, NewAccountForm, LoginForm
+from freehg.repos.forms import (NewRepoForm, NewAccountForm, LoginForm,
+        EditRepoForm)
 
 from mercurial import hg, ui, util
 from binascii import hexlify, unhexlify
             content=u''.join(content),
         ), context_instance=RequestContext(request)
     )
+
+@login_required
+def edit_repo(request, username, reponame):
+    if username != request.user.username:
+        from django.http import HttpResponseForbidden
+        return HttpResponseForbidden(
+                "You don't have permission to edit this repository.")
+    repo = get_object_or_404(Repo, owner__username=username, name=reponame)
+
+    if request.method == 'POST':
+        form = EditRepoForm(request.POST)
+        if form.is_valid():
+            repo.long_name = form.cleaned_data['long_name']
+            repo.description = form.cleaned_data['description']
+            repo.save()
+            return HttpResponseRedirect(repo.get_absolute_url())
+    else:
+        form = EditRepoForm({'long_name':repo.long_name,
+                'description':repo.description})
+    return render_to_response('repos/edit.html',
+        dict(
+            repo=repo,
+            form=form,
+        ), context_instance=RequestContext(request)
+    )

templates/repos/edit.html

+{% extends "base.html" %}
+
+{% block title %}Editing information for {{repo.get_long_name}}{% endblock %}
+
+{% block content %}
+<div class="span-14 last">
+    <form method="POST" action=".">
+        <fieldset>
+            <legend>Edit information for <a href="{{repo.get_absolute_url}}">{{repo.get_long_name}}</a>:</legend>
+            {% for field in form %}
+                    <div class="form-row {%if field.field.required %}required{%endif%} {%if field.errors%}errors{%endif%}">
+                        {% if field.errors %}{{field.errors}}{% endif %}
+                        <p>
+                            {{field.label_tag}}<br />
+                            {% if field.help_text %}
+                                <span class="help-text">({{field.help_text}})</span><br />
+                            {%endif%}
+                            {{field}}
+                        </p>
+                    </div>
+            {% endfor %}
+            <input type="submit" />
+        </fieldset>
+    </form>
+</div>
+
+{% endblock %}
+
     (r'^about/', direct_to_template, {'template':'about.html'}),
 
     (r'^u/(?P<username>\w+)/(?P<reponame>\w+)/$', 'freehg.repos.views.summary'),
+    (r'^u/(?P<username>\w+)/(?P<reponame>\w+)/edit/$',
+            'freehg.repos.views.edit_repo'),
 
     # Uncomment this for admin:
     (r'^admin/', include('django.contrib.admin.urls')),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.