diff options
author | eliott <eliott@cactuswax.net> | 2007-12-30 01:42:55 +0100 |
---|---|---|
committer | eliott <eliott@cactuswax.net> | 2007-12-30 01:42:55 +0100 |
commit | 3e297efad8e6dbb7622cedd68a2457f00dd09080 (patch) | |
tree | 1d66d932fa8e90bfa2c71f92d77a24b823831540 | |
parent | ff6d99b054efddb0725b0ddcbc81c58f7c8ce375 (diff) | |
download | archweb-3e297efad8e6dbb7622cedd68a2457f00dd09080.tar.gz archweb-3e297efad8e6dbb7622cedd68a2457f00dd09080.tar.xz |
Massive retab fest.
Also added vim command comment to the end of files.
-rw-r--r-- | devel/views.py | 3 | ||||
-rw-r--r-- | feeds.py | 2 | ||||
-rw-r--r-- | lib/markdown.py | 1 | ||||
-rw-r--r-- | lib/sitelogin.py | 2 | ||||
-rw-r--r-- | lib/utils.py | 2 | ||||
-rwxr-xr-x | manage.py | 3 | ||||
-rw-r--r-- | news/models.py | 27 | ||||
-rw-r--r-- | news/views.py | 3 | ||||
-rw-r--r-- | packages/models.py | 150 | ||||
-rw-r--r-- | packages/templatetags/package_extras.py | 37 | ||||
-rw-r--r-- | packages/views.py | 3 | ||||
-rw-r--r-- | public/models.py | 2 | ||||
-rw-r--r-- | public/templatetags/validation.py | 15 | ||||
-rw-r--r-- | public/views.py | 3 | ||||
-rw-r--r-- | settings.py | 2 | ||||
-rw-r--r-- | todolists/models.py | 44 | ||||
-rw-r--r-- | todolists/views.py | 3 | ||||
-rw-r--r-- | urls.py | 1 | ||||
-rw-r--r-- | wiki/models.py | 23 | ||||
-rw-r--r-- | wiki/templatetags/wikitags.py | 95 | ||||
-rw-r--r-- | wiki/views.py | 3 |
21 files changed, 238 insertions, 186 deletions
diff --git a/devel/views.py b/devel/views.py index f206829..c2cdb70 100644 --- a/devel/views.py +++ b/devel/views.py @@ -66,3 +66,6 @@ def guide(request): return render_response(request, 'devel/pkgmaint_guide.txt', {'errors':errors,'email':request.user.email}) return HttpResponse(file(DATA_DIR + '/pkgmaint_guide.txt').read(), mimetype='text/plain') + +# vim: set ts=4 sw=4 et: + @@ -31,3 +31,5 @@ class NewsFeed(Feed): def item_author_name(self, item): return item.author.get_full_name() +# vim: set ts=4 sw=4 et: + diff --git a/lib/markdown.py b/lib/markdown.py index 6b3e57a..d780994 100644 --- a/lib/markdown.py +++ b/lib/markdown.py @@ -1868,6 +1868,7 @@ Apr. 2004: Manfred's version at http://www.dwerg.net/projects/markdown/ """ +# vim: set ts=4 sw=4 et: diff --git a/lib/sitelogin.py b/lib/sitelogin.py index 3edec7c..5372109 100644 --- a/lib/sitelogin.py +++ b/lib/sitelogin.py @@ -11,3 +11,5 @@ class SiteLogin: else: return HttpResponseRedirect('%s?next=%s' % (self.login_path, request.path)) +# vim: set ts=4 sw=4 et: + diff --git a/lib/utils.py b/lib/utils.py index 59df963..0813ac2 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -32,3 +32,5 @@ def render_response(req, *args, **kwargs): kwargs['context_instance'] = RequestContext(req) return render_to_response(*args, **kwargs) +# vim: set ts=4 sw=4 et: + @@ -9,3 +9,6 @@ except ImportError: if __name__ == "__main__": execute_manager(settings) + +# vim: set ts=4 sw=4 et: + diff --git a/news/models.py b/news/models.py index 68d2865..14837a5 100644 --- a/news/models.py +++ b/news/models.py @@ -4,16 +4,19 @@ import re from archweb_dev.utils import Stripper class News(models.Model): - id = models.AutoField(primary_key=True) - author = models.ForeignKey(User) - postdate = models.DateField(auto_now_add=True) - title = models.CharField(maxlength=255) - content = models.TextField() - class Meta: - db_table = 'news' - verbose_name_plural = 'news' - get_latest_by = 'postdate' - ordering = ['-postdate', '-id'] + id = models.AutoField(primary_key=True) + author = models.ForeignKey(User) + postdate = models.DateField(auto_now_add=True) + title = models.CharField(maxlength=255) + content = models.TextField() + class Meta: + db_table = 'news' + verbose_name_plural = 'news' + get_latest_by = 'postdate' + ordering = ['-postdate', '-id'] + + def get_absolute_url(self): + return '/news/%i/' % self.id + +# vim: set ts=4 sw=4 et: - def get_absolute_url(self): - return '/news/%i/' % self.id diff --git a/news/views.py b/news/views.py index 4e4b4f0..b618e2f 100644 --- a/news/views.py +++ b/news/views.py @@ -80,3 +80,6 @@ def edit(request, newsid): form = forms.FormWrapper(manipulator, data, errors) return render_response(request, 'news/add.html', {'form': form, 'news':news}) + +# vim: set ts=4 sw=4 et: + diff --git a/packages/models.py b/packages/models.py index d9de3b1..bce638d 100644 --- a/packages/models.py +++ b/packages/models.py @@ -3,90 +3,92 @@ from django.contrib.auth.models import User import re class PackageManager(models.Manager): - def get_flag_stats(self): - results = [] - # first the orphans - unflagged = self.filter(maintainer=0).count() - flagged = self.filter(maintainer=0).filter(needupdate=True).count() - results.append((User(id=0,first_name='Orphans'), unflagged, flagged)) - # now the rest - for maint in User.objects.all().order_by('first_name'): - unflagged = self.filter(maintainer=maint.id).count() - flagged = self.filter(maintainer=maint.id).filter(needupdate=True).count() - results.append((maint, unflagged, flagged)) - return results + def get_flag_stats(self): + results = [] + # first the orphans + unflagged = self.filter(maintainer=0).count() + flagged = self.filter(maintainer=0).filter(needupdate=True).count() + results.append((User(id=0,first_name='Orphans'), unflagged, flagged)) + # now the rest + for maint in User.objects.all().order_by('first_name'): + unflagged = self.filter(maintainer=maint.id).count() + flagged = self.filter(maintainer=maint.id).filter(needupdate=True).count() + results.append((maint, unflagged, flagged)) + return results class Category(models.Model): - id = models.AutoField(primary_key=True) - category = models.CharField(maxlength=255) - class Meta: - db_table = 'categories' - verbose_name_plural = 'categories' + id = models.AutoField(primary_key=True) + category = models.CharField(maxlength=255) + class Meta: + db_table = 'categories' + verbose_name_plural = 'categories' class Repo(models.Model): - id = models.AutoField(primary_key=True) - name = models.CharField(maxlength=255) - class Meta: - db_table = 'repos' + id = models.AutoField(primary_key=True) + name = models.CharField(maxlength=255) + class Meta: + db_table = 'repos' ordering = ['name'] - def last_update(self): - try: - latest = Package.objects.filter(repo__name__exact=self.name).order_by('-last_update')[0] - return latest.last_update - except IndexError: - return "N/A" + def last_update(self): + try: + latest = Package.objects.filter(repo__name__exact=self.name).order_by('-last_update')[0] + return latest.last_update + except IndexError: + return "N/A" class Package(models.Model): - id = models.AutoField(primary_key=True) - repo = models.ForeignKey(Repo) - maintainer = models.ForeignKey(User) - category = models.ForeignKey(Category) - needupdate = models.BooleanField(default=False) - pkgname = models.CharField(maxlength=255) - pkgver = models.CharField(maxlength=255) - pkgrel = models.CharField(maxlength=255) - pkgdesc = models.CharField(maxlength=255) - url = models.URLField() - sources = models.TextField() - depends = models.TextField() - last_update = models.DateTimeField(null=True, blank=True) - objects = PackageManager() - class Meta: - db_table = 'packages' - get_latest_by = 'last_update' + id = models.AutoField(primary_key=True) + repo = models.ForeignKey(Repo) + maintainer = models.ForeignKey(User) + category = models.ForeignKey(Category) + needupdate = models.BooleanField(default=False) + pkgname = models.CharField(maxlength=255) + pkgver = models.CharField(maxlength=255) + pkgrel = models.CharField(maxlength=255) + pkgdesc = models.CharField(maxlength=255) + url = models.URLField() + sources = models.TextField() + depends = models.TextField() + last_update = models.DateTimeField(null=True, blank=True) + objects = PackageManager() + class Meta: + db_table = 'packages' + get_latest_by = 'last_update' - def get_absolute_url(self): - return '/packages/%i/' % self.id + def get_absolute_url(self): + return '/packages/%i/' % self.id - def depends_urlize(self): - urls = '' - for dep in self.depends.split(' '): - # shave off any version qualifiers - nameonly = re.match(r"([a-z0-9-]+)", dep).group(1) - try: - p = Package.objects.filter(pkgname=nameonly)[0] - except IndexError: - # couldn't find a package in the DB -- it might be a virtual depend - urls = urls + '<li>' + dep + '</li>' - continue - url = '<li><a href="/packages/' + str(p.id) + '">' + dep + '</a></li>' - urls = urls + url - return urls + def depends_urlize(self): + urls = '' + for dep in self.depends.split(' '): + # shave off any version qualifiers + nameonly = re.match(r"([a-z0-9-]+)", dep).group(1) + try: + p = Package.objects.filter(pkgname=nameonly)[0] + except IndexError: + # couldn't find a package in the DB -- it might be a virtual depend + urls = urls + '<li>' + dep + '</li>' + continue + url = '<li><a href="/packages/' + str(p.id) + '">' + dep + '</a></li>' + urls = urls + url + return urls - def sources_urlize(self): - urls = '' - for source in self.sources.split(' '): - if re.search('://', source): - url = '<li><a href="' + source + '">' + source + '</a></li>' - else: - url = '<li>' + source + '</li>' - urls = urls + url - return urls + def sources_urlize(self): + urls = '' + for source in self.sources.split(' '): + if re.search('://', source): + url = '<li><a href="' + source + '">' + source + '</a></li>' + else: + url = '<li>' + source + '</li>' + urls = urls + url + return urls class PackageFile(models.Model): - id = models.AutoField(primary_key=True) - pkg = models.ForeignKey(Package) - path = models.CharField(maxlength=255) - class Meta: - db_table = 'packages_files' + id = models.AutoField(primary_key=True) + pkg = models.ForeignKey(Package) + path = models.CharField(maxlength=255) + class Meta: + db_table = 'packages_files' + +# vim: set ts=4 sw=4 et: diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py index 8b55221..9f16558 100644 --- a/packages/templatetags/package_extras.py +++ b/packages/templatetags/package_extras.py @@ -3,26 +3,29 @@ from django import template register = template.Library() class BuildQueryStringNode(template.Node): - def __init__(self, sortfield): - self.sortfield = sortfield - def render(self, context): - qs = context['querystring'].copy() - if qs.has_key('sort') and qs['sort'] == self.sortfield: - qs['sort'] = '-' + self.sortfield - else: - qs['sort'] = self.sortfield - return '?' + qs.urlencode() + def __init__(self, sortfield): + self.sortfield = sortfield + def render(self, context): + qs = context['querystring'].copy() + if qs.has_key('sort') and qs['sort'] == self.sortfield: + qs['sort'] = '-' + self.sortfield + else: + qs['sort'] = self.sortfield + return '?' + qs.urlencode() @register.tag(name='buildsortqs') def do_buildsortqs(parser, token): - try: - tagname, sortfield = token.split_contents() - except ValueError: - raise template.TemplateSyntaxError, "%r tag requires a single argument" % tagname - if not (sortfield[0] == sortfield[-1] and sortfield[0] in ('"', "'")): - raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tagname - return BuildQueryStringNode(sortfield[1:-1]) + try: + tagname, sortfield = token.split_contents() + except ValueError: + raise template.TemplateSyntaxError, "%r tag requires a single argument" % tagname + if not (sortfield[0] == sortfield[-1] and sortfield[0] in ('"', "'")): + raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tagname + return BuildQueryStringNode(sortfield[1:-1]) @register.filter(name='space2br') def space2br(value): - return value.replace(' ', '<br />') + return value.replace(' ', '<br />') + +# vim: set ts=4 sw=4 et: + diff --git a/packages/views.py b/packages/views.py index aaf4dee..ddb2adb 100644 --- a/packages/views.py +++ b/packages/views.py @@ -170,3 +170,6 @@ def unflag(request, pkgid): pkg.needupdate = 0 pkg.save() return HttpResponseRedirect('/packages/%d/' % (pkg.id)) + +# vim: set ts=4 sw=4 et: + diff --git a/public/models.py b/public/models.py index 883675b..79afb6f 100644 --- a/public/models.py +++ b/public/models.py @@ -48,3 +48,5 @@ class UserProfile(models.Model): verbose_name = 'Additional Profile Data' verbose_name_plural = 'Additional Profile Data' +# vim: set ts=4 sw=4 et: + diff --git a/public/templatetags/validation.py b/public/templatetags/validation.py index 40c48da..38a4053 100644 --- a/public/templatetags/validation.py +++ b/public/templatetags/validation.py @@ -4,9 +4,12 @@ register = template.Library() @register.inclusion_tag('errors.html') def print_errors(errors): - errs = [] - for e,msg in errors.iteritems(): - errmsg = str(msg[0]) - # hack -- I'm a python idiot - errs.append( (e, errmsg[2:-2]) ) - return {'errors': errs} + errs = [] + for e,msg in errors.iteritems(): + errmsg = str(msg[0]) + # hack -- I'm a python idiot + errs.append( (e, errmsg[2:-2]) ) + return {'errors': errs} + +# vim: set ts=4 sw=4 et: + diff --git a/public/views.py b/public/views.py index 2cda74b..9c41ece 100644 --- a/public/views.py +++ b/public/views.py @@ -57,3 +57,6 @@ def robots(request): def denied(request): return render_response(request, 'public/denied.html') + +# vim: set ts=4 sw=4 et: + diff --git a/settings.py b/settings.py index 1c858ea..4f50cd3 100644 --- a/settings.py +++ b/settings.py @@ -91,3 +91,5 @@ INSTALLED_APPS = ( 'archweb_dev.wiki' ) +# vim: set ts=4 sw=4 et: + diff --git a/todolists/models.py b/todolists/models.py index c5893f0..ec24d5e 100644 --- a/todolists/models.py +++ b/todolists/models.py @@ -3,29 +3,31 @@ from django.contrib.auth.models import User from archweb_dev.packages.models import Package class TodolistManager(models.Manager): - def get_incomplete(self): - results = [] - for l in self.all().order_by('-date_added'): - if TodolistPkg.objects.filter(list=l.id).filter(complete=False).count() > 0: - results.append(l) - return results + def get_incomplete(self): + results = [] + for l in self.all().order_by('-date_added'): + if TodolistPkg.objects.filter(list=l.id).filter(complete=False).count() > 0: + results.append(l) + return results class Todolist(models.Model): - id = models.AutoField(primary_key=True) - creator = models.ForeignKey(User) - name = models.CharField(maxlength=255) - description = models.TextField() - date_added = models.DateField(auto_now_add=True) - objects = TodolistManager() - class Meta: - db_table = 'todolists' + id = models.AutoField(primary_key=True) + creator = models.ForeignKey(User) + name = models.CharField(maxlength=255) + description = models.TextField() + date_added = models.DateField(auto_now_add=True) + objects = TodolistManager() + class Meta: + db_table = 'todolists' class TodolistPkg(models.Model): - id = models.AutoField(primary_key=True) - list = models.ForeignKey(Todolist) - pkg = models.ForeignKey(Package) - complete = models.BooleanField(default=False) - class Meta: - db_table = 'todolists_pkgs' - unique_together = (('list','pkg'),) + id = models.AutoField(primary_key=True) + list = models.ForeignKey(Todolist) + pkg = models.ForeignKey(Package) + complete = models.BooleanField(default=False) + class Meta: + db_table = 'todolists_pkgs' + unique_together = (('list','pkg'),) + +# vim: set ts=4 sw=4 et: diff --git a/todolists/views.py b/todolists/views.py index 225da15..cce92a6 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -61,3 +61,6 @@ def add(request): pass return HttpResponseRedirect('/todo/') return render_response(request, 'todolists/add.html') + +# vim: set ts=4 sw=4 et: + @@ -77,3 +77,4 @@ if settings.DEBUG == True: {'document_root': settings.DEPLOY_PATH+'/media'})) # vim: set ts=4 sw=4 et: + diff --git a/wiki/models.py b/wiki/models.py index 2b8b16f..85f0726 100644 --- a/wiki/models.py +++ b/wiki/models.py @@ -2,15 +2,18 @@ from django.db import models from django.contrib.auth.models import User class Wikipage(models.Model): - """Wiki page storage""" - title = models.CharField(maxlength=255) - content = models.TextField() - last_author = models.ForeignKey(User) - class Meta: - db_table = 'wikipages' + """Wiki page storage""" + title = models.CharField(maxlength=255) + content = models.TextField() + last_author = models.ForeignKey(User) + class Meta: + db_table = 'wikipages' - def editurl(self): - return "/wiki/edit/" + self.title + "/" + def editurl(self): + return "/wiki/edit/" + self.title + "/" + + def __repr__(self): + return self.title + +# vim: set ts=4 sw=4 et: - def __repr__(self): - return self.title diff --git a/wiki/templatetags/wikitags.py b/wiki/templatetags/wikitags.py index e8a8a03..c8c1cd3 100644 --- a/wiki/templatetags/wikitags.py +++ b/wiki/templatetags/wikitags.py @@ -6,52 +6,55 @@ import re register = Library() class WikiProcessor: - def run(self, lines): - in_table = False - for i in range(len(lines)): - # Linebreaks - lines[i] = re.sub("%%", "<br />", lines[i]) - # Internal Links - lines[i] = re.sub("\(\(([A-z0-9 :/-]+)\)\)", "<a href=\"/wiki/\\1\">\\1</a>", lines[i]) - # Small Text - lines[i] = re.sub("----([^----]+)----", "<span style=\"font-size:x-small\">\\1</span>", lines[i]) - lines[i] = re.sub("--([^--]+)--", "<span style=\"font-size:small\">\\1</span>", lines[i]) - # TT text - lines[i] = re.sub("\{\{([^}\}]+)\}\}", "<tt>\\1</tt>", lines[i]) - # Tables - m = re.match("(\|\|)", lines[i]) - if m: - count = len(re.findall("(\|\|+)", lines[i])) - first = True - m2 = re.search("(\|\|+)", lines[i]) - while m2 and count: - count -= 1 - colspan = len(m2.group(1)) / 2 - if first: - repl = "<td colspan=\"%d\">" % (colspan) - first = False - elif count == 0: - repl = "</td>" - else: - repl = "</td><td colspan=\"%d\">" % (colspan) - lines[i] = re.sub("(\|\|+)", repl, lines[i], 1) - # find the next chunk - m2 = re.search("(\|\|+)", lines[i]) - lines[i] = "<tr>" + lines[i] + "</tr>" - if not in_table: - lines[i] = "<table>" + lines[i] - in_table = True - elif in_table: - lines[i] = "</table>" + lines[i] - in_table = False - # close leftover table, if open - if in_table: - lines[len(lines)] = lines[len(lines)] + "</table>" - return lines + def run(self, lines): + in_table = False + for i in range(len(lines)): + # Linebreaks + lines[i] = re.sub("%%", "<br />", lines[i]) + # Internal Links + lines[i] = re.sub("\(\(([A-z0-9 :/-]+)\)\)", "<a href=\"/wiki/\\1\">\\1</a>", lines[i]) + # Small Text + lines[i] = re.sub("----([^----]+)----", "<span style=\"font-size:x-small\">\\1</span>", lines[i]) + lines[i] = re.sub("--([^--]+)--", "<span style=\"font-size:small\">\\1</span>", lines[i]) + # TT text + lines[i] = re.sub("\{\{([^}\}]+)\}\}", "<tt>\\1</tt>", lines[i]) + # Tables + m = re.match("(\|\|)", lines[i]) + if m: + count = len(re.findall("(\|\|+)", lines[i])) + first = True + m2 = re.search("(\|\|+)", lines[i]) + while m2 and count: + count -= 1 + colspan = len(m2.group(1)) / 2 + if first: + repl = "<td colspan=\"%d\">" % (colspan) + first = False + elif count == 0: + repl = "</td>" + else: + repl = "</td><td colspan=\"%d\">" % (colspan) + lines[i] = re.sub("(\|\|+)", repl, lines[i], 1) + # find the next chunk + m2 = re.search("(\|\|+)", lines[i]) + lines[i] = "<tr>" + lines[i] + "</tr>" + if not in_table: + lines[i] = "<table>" + lines[i] + in_table = True + elif in_table: + lines[i] = "</table>" + lines[i] + in_table = False + # close leftover table, if open + if in_table: + lines[len(lines)] = lines[len(lines)] + "</table>" + return lines @register.filter def wikify(value): - md = markdown.Markdown(value) - md.preprocessors.insert(0, WikiProcessor()) - html = md.toString() - return html + md = markdown.Markdown(value) + md.preprocessors.insert(0, WikiProcessor()) + html = md.toString() + return html + +# vim: set ts=4 sw=4 et: + diff --git a/wiki/views.py b/wiki/views.py index 9f7bd78..796f5f9 100644 --- a/wiki/views.py +++ b/wiki/views.py @@ -59,3 +59,6 @@ def delete(request): return HttpResponseRedirect("/wiki/") page.delete() return HttpResponseRedirect("/wiki/") + +# vim: set ts=4 sw=4 et: + |