Commits

Steve Losh  committed 825cee4

Add the repo list.

  • Participants
  • Parent commits df25941

Comments (0)

Files changed (9)

 
 admin.site.groups = {
     0: {
+        'name': 'Mercurial Data',
+        'apps': ['mercurial_data'],
+        'classes': ['collapse-open'],
+    },
+    1: {
         'name': 'Feedback',
         'apps': ['feedback'],
         'classes': ['collapse-open'],
     },
-    1: {
+    2: {
         'name': 'Flat Pages',
         'apps': ['flatpages'],
         'classes': ['collapse-open'],
     },
-    2: {
+    3: {
         'name': 'Site Administration',
         'apps': ['grappelli', 'sites', 'auth'],
         'classes': ['collapse-closed'],

File media/css/base.css

     color: #E2003B;
     font-style: italic;
 }
+
+ul#repo-list {
+    list-style-type: none;
+}
+ul#repo-list li {
+    margin-left: 0;
+    font-size: 1.25em;
+    line-height: 1.2em;
+}

File mercurial_data/__init__.py

Empty file added.

File mercurial_data/admin.py

+from django.contrib import admin
+from noodlebucket.mercurial_data.models import Repository
+
+class RepositoryAdmin(admin.ModelAdmin):
+    search_fields = ('user_name', 'repo_name')
+    list_display = ('repo_name', 'user_name', 'parent')
+    list_filter = ('refreshed', 'created', 'updated')
+
+admin.site.register(Repository, RepositoryAdmin)

File mercurial_data/models.py

+from django.db import models
+
+class Repository(models.Model):
+    """A Mercurial repository on BitBucket."""
+    
+    user_name = models.CharField(
+        max_length=100
+    )
+    repo_name = models.CharField(
+        max_length=200
+    )
+    parent = models.ForeignKey(
+        'self', null=True, blank=True
+    )
+    refreshed = models.DateTimeField(
+        null=True, blank=True
+    )
+    
+    created = models.DateTimeField(editable=False, auto_now_add=True)
+    updated = models.DateTimeField(editable=False, auto_now=True)
+    
+    class Meta:
+        ordering = ['-created']
+        verbose_name_plural = "repositories"
+    
+    
+    def __unicode__(self):
+        return u"%s/%s" % (self.user_name, self.repo_name)
+    
+

File mercurial_data/views.py

+from django.core.urlresolvers import reverse
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+from noodlebucket.mercurial_data.models import Repository
+
+def repo_list(request):
+    """List all the repos that Noodle Bucket tracks."""
+    repos = sorted(
+        Repository.objects.all(),
+        key=lambda r: (r.user_name, r.repo_name),
+    )
+    
+    return render_to_response(
+        'repos/repo_list.html',
+        { 'repos': repos },
+        context_instance=RequestContext(request)
+    )
+
+
+def repo(request, user_name=None, repo_name=None):
+    pass
+
     'django.contrib.flatpages',
     'django.contrib.markup',
     'noodlebucket.feedback',
+    'noodlebucket.mercurial_data',
     'noodlebucket.util',
     'gravatar',
     'typogrify',

File templates/repos/repo_list.html

+{% extends "base.html" %}
+
+{% block content %}
+    <p>
+        Noodle bucket is a proof-of-concept site to provide a network graph
+        for BitBucket repositories.
+    </p>
+    
+    <h2>Repositories</h2>
+    
+    <ul id="repo-list">
+        {% for repo in repos %}
+            <li><a href="{% url repo user_name=repo.user_name,repo_name=repo.repo_name %}">{{ repo.user_name }}/{{ repo.repo_name }}</a></li>
+        {% endfor %}
+    </ul>
+{% endblock %}
     url(r'^feedback/', include('noodlebucket.feedback.urls')),
 )
 
+urlpatterns += patterns('noodlebucket.mercurial_data.views',
+    url(r'^$', 'repo_list', name="repo-list"),
+    url(r'^repo/(?P<user_name>[^/]+)/(?P<repo_name>[^/]+)/$', 'repo', name="repo"),
+)
+
 if settings.DEBUG:
     urlpatterns += patterns('',
         (r'^media/(?P<path>.*)$',