Commit 3e297efa authored by eliott's avatar eliott
Browse files

Massive retab fest.

Also added vim command comment to the end of files.
parent ff6d99b0
......@@ -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 @@ def item_pubdate(self, item):
def item_author_name(self, item):
return item.author.get_full_name()
# vim: set ts=4 sw=4 et:
......@@ -1868,6 +1868,7 @@ def cmd_line(args):
"""
# vim: set ts=4 sw=4 et:
......
......@@ -11,3 +11,5 @@ def process_request(self, request):
else:
return HttpResponseRedirect('%s?next=%s' % (self.login_path, request.path))
# vim: set ts=4 sw=4 et:
......@@ -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 @@
if __name__ == "__main__":
execute_manager(settings)
# vim: set ts=4 sw=4 et:
......@@ -4,16 +4,19 @@
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
......@@ -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:
......@@ -3,90 +3,92 @@
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:
......@@ -3,26 +3,29 @@
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:
......@@ -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:
......@@ -48,3 +48,5 @@ class Meta:
verbose_name = 'Additional Profile Data'
verbose_name_plural = 'Additional Profile Data'
# vim: set ts=4 sw=4 et:
......@@ -4,9 +4,12 @@
@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:
......@@ -57,3 +57,6 @@ def robots(request):
def denied(request):
return render_response(request, 'public/denied.html')
# vim: set ts=4 sw=4 et:
......@@ -91,3 +91,5 @@
'archweb_dev.wiki'
)
# vim: set ts=4 sw=4 et:
......@@ -3,29 +3,31 @@
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:
......@@ -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 @@
{'document_root': settings.DEPLOY_PATH+'/media'}))
# vim: set ts=4 sw=4 et:
......@@ -2,15 +2,18 @@
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
......@@ -6,52 +6,55 @@
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:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment