summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreliott <eliott@cactuswax.net>2008-03-08 00:13:41 -0800
committereliott <eliott@cactuswax.net>2008-03-08 00:13:41 -0800
commit9b7b5122544283fc32d81d785e94c5f4aacc0109 (patch)
treeba117f7fadc24737920fa4f1b9a711157e629cc5
parent7e2d0f2f0cd8f176cf82c02d704ad4fe25a07b3b (diff)
Moved models around
-rw-r--r--devel/models.py56
-rw-r--r--devel/views.py10
-rw-r--r--main/__init__.py (renamed from lib/__init__.py)0
-rw-r--r--main/markdown.py (renamed from lib/markdown.py)0
-rw-r--r--main/models.py214
-rw-r--r--main/sitelogin.py (renamed from lib/sitelogin.py)0
-rw-r--r--main/utils.py (renamed from lib/utils.py)0
-rw-r--r--news/models.py21
-rw-r--r--news/views.py4
-rw-r--r--packages/models.py94
-rw-r--r--packages/views.py4
-rw-r--r--settings.py3
-rw-r--r--todolists/models.py33
-rw-r--r--todolists/views.py5
-rw-r--r--wiki/models.py19
-rw-r--r--wiki/templatetags/wikitags.py2
-rw-r--r--wiki/views.py4
17 files changed, 228 insertions, 241 deletions
diff --git a/devel/models.py b/devel/models.py
deleted file mode 100644
index d78989f5..00000000
--- a/devel/models.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from django.db import models
-from django.contrib.auth.models import User
-
-class Mirror(models.Model):
- id = models.AutoField(primary_key=True)
- domain = models.CharField(maxlength=255)
- country = models.CharField(maxlength=255)
- url = models.CharField(maxlength=255)
- protocol_list = models.CharField(maxlength=255, null=True, blank=True)
- admin_email = models.CharField(maxlength=255, null=True, blank=True)
- def __str__(self):
- return self.domain
- class Meta:
- db_table = 'common_mirror'
- class Admin:
- list_display = ('domain', 'country')
- list_filter = ('country',)
- ordering = ['domain']
- search_fields = ('domain')
- pass
-
-class Donator(models.Model):
- id = models.AutoField(primary_key=True)
- name = models.CharField(maxlength=255)
- def __str__(self):
- return self.name
- class Meta:
- db_table = 'common_donator'
- class Admin:
- ordering = ['name']
- search_fields = ('name')
- pass
-
-class UserProfile(models.Model):
- id = models.AutoField(primary_key=True) # not technically needed
- notify = models.BooleanField("Send notifications", default=True, help_text="When enabled, user will recieve 'flag out of date' notifications")
- alias = models.CharField(core=True, maxlength=50, help_text="Required field")
- public_email = models.CharField(core=True, maxlength=50, help_text="Required field")
- other_contact = models.CharField(maxlength=100, null=True, blank=True)
- website = models.URLField(null=True, blank=True)
- yob = models.IntegerField(null=True, blank=True)
- location = models.CharField(maxlength=50, null=True, blank=True)
- languages = models.CharField(maxlength=50, null=True, blank=True)
- interests = models.CharField(maxlength=255, null=True, blank=True)
- occupation = models.CharField(maxlength=50, null=True, blank=True)
- roles = models.CharField(maxlength=255, null=True, blank=True)
- favorite_distros = models.CharField(maxlength=255, null=True, blank=True)
- picture = models.FileField(upload_to='devs', default='devs/silhouette.png')
- user = models.ForeignKey(User, edit_inline=models.STACKED, num_in_admin=1, min_num_in_admin=1, max_num_in_admin=1, num_extra_on_change=0, unique=True)
- class Meta:
- db_table = 'user_profiles'
- verbose_name = 'Additional Profile Data'
- verbose_name_plural = 'Additional Profile Data'
-
-# vim: set ts=4 sw=4 et:
-
diff --git a/devel/views.py b/devel/views.py
index 65dde8ae..b073d29c 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -2,13 +2,9 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core import validators
-from archweb_dev.lib.utils import render_response
-from archweb_dev.packages.models import Package, Repo
-from archweb_dev.todolists.models import Todolist, TodolistPkg
-from archweb_dev.lib.utils import validate
-from archweb_dev.devel.models import UserProfile
-from archweb_dev.news.models import News
-from archweb_dev.devel.models import Donator, Mirror
+from archweb_dev.main.utils import render_response, validate
+from archweb_dev.main.models import Package, Repo, Todolist, TodolistPkg
+from archweb_dev.main.models import UserProfile, News, Donator, Mirror
from django.http import HttpResponse
from django.template import Context, loader
diff --git a/lib/__init__.py b/main/__init__.py
index e69de29b..e69de29b 100644
--- a/lib/__init__.py
+++ b/main/__init__.py
diff --git a/lib/markdown.py b/main/markdown.py
index d780994f..d780994f 100644
--- a/lib/markdown.py
+++ b/main/markdown.py
diff --git a/main/models.py b/main/models.py
new file mode 100644
index 00000000..a246e335
--- /dev/null
+++ b/main/models.py
@@ -0,0 +1,214 @@
+from django.db import models
+from django.contrib.auth.models import User
+import re
+
+
+###########################
+### User Profile Class ####
+###########################
+class UserProfile(models.Model):
+ id = models.AutoField(primary_key=True) # not technically needed
+ notify = models.BooleanField("Send notifications", default=True, help_text="When enabled, user will recieve 'flag out of date' notifications")
+ alias = models.CharField(core=True, maxlength=50, help_text="Required field")
+ public_email = models.CharField(core=True, maxlength=50, help_text="Required field")
+ other_contact = models.CharField(maxlength=100, null=True, blank=True)
+ website = models.URLField(null=True, blank=True)
+ yob = models.IntegerField(null=True, blank=True)
+ location = models.CharField(maxlength=50, null=True, blank=True)
+ languages = models.CharField(maxlength=50, null=True, blank=True)
+ interests = models.CharField(maxlength=255, null=True, blank=True)
+ occupation = models.CharField(maxlength=50, null=True, blank=True)
+ roles = models.CharField(maxlength=255, null=True, blank=True)
+ favorite_distros = models.CharField(maxlength=255, null=True, blank=True)
+ picture = models.FileField(upload_to='devs', default='devs/silhouette.png')
+ user = models.ForeignKey(User, related_name='userprofile_user', edit_inline=models.STACKED, num_in_admin=1, min_num_in_admin=1, max_num_in_admin=1, num_extra_on_change=0, unique=True)
+ class Meta:
+ db_table = 'user_profiles'
+ verbose_name = 'Additional Profile Data'
+ verbose_name_plural = 'Additional Profile Data'
+
+
+#######################
+### Manager Classes ###
+#######################
+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
+
+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
+
+
+#############################
+### General Model Classes ###
+#############################
+class Mirror(models.Model):
+ id = models.AutoField(primary_key=True)
+ domain = models.CharField(maxlength=255)
+ country = models.CharField(maxlength=255)
+ url = models.CharField(maxlength=255)
+ protocol_list = models.CharField(maxlength=255, null=True, blank=True)
+ admin_email = models.CharField(maxlength=255, null=True, blank=True)
+ def __str__(self):
+ return self.domain
+ class Meta:
+ db_table = 'common_mirror'
+ class Admin:
+ list_display = ('domain', 'country')
+ list_filter = ('country',)
+ ordering = ['domain']
+ search_fields = ('domain')
+ pass
+
+class Donator(models.Model):
+ id = models.AutoField(primary_key=True)
+ name = models.CharField(maxlength=255)
+ def __str__(self):
+ return self.name
+ class Meta:
+ db_table = 'common_donator'
+ class Admin:
+ ordering = ['name']
+ search_fields = ('name')
+ pass
+
+class News(models.Model):
+ id = models.AutoField(primary_key=True)
+ author = models.ForeignKey(User, related_name='news_author')
+ 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
+
+class Category(models.Model):
+ 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'
+ 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"
+
+class Package(models.Model):
+ id = models.AutoField(primary_key=True)
+ repo = models.ForeignKey(Repo)
+ maintainer = models.ForeignKey(User, related_name='package_maintainer')
+ 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 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
+
+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'
+
+class Todolist(models.Model):
+ id = models.AutoField(primary_key=True)
+ creator = models.ForeignKey(User, related_name='todolist_creator')
+ 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'),)
+
+class Wikipage(models.Model):
+ """Wiki page storage"""
+ title = models.CharField(maxlength=255)
+ content = models.TextField()
+ last_author = models.ForeignKey(User, related_name='wikipage_last_author')
+ class Meta:
+ db_table = 'wikipages'
+
+ def editurl(self):
+ return "/wiki/edit/" + self.title + "/"
+
+ def __repr__(self):
+ return self.title
+
+# vim: set ts=4 sw=4 et:
+
diff --git a/lib/sitelogin.py b/main/sitelogin.py
index 53721095..53721095 100644
--- a/lib/sitelogin.py
+++ b/main/sitelogin.py
diff --git a/lib/utils.py b/main/utils.py
index 0813ac22..0813ac22 100644
--- a/lib/utils.py
+++ b/main/utils.py
diff --git a/news/models.py b/news/models.py
deleted file mode 100644
index b8709b48..00000000
--- a/news/models.py
+++ /dev/null
@@ -1,21 +0,0 @@
-from django.db import models
-from django.contrib.auth.models import User
-import re
-
-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']
-
- def get_absolute_url(self):
- return '/news/%i/' % self.id
-
-# vim: set ts=4 sw=4 et:
-
diff --git a/news/views.py b/news/views.py
index b618e2f9..cfa2bcd7 100644
--- a/news/views.py
+++ b/news/views.py
@@ -3,8 +3,8 @@ from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import User
from django import forms
-from archweb_dev.lib.utils import render_response
-from archweb_dev.news.models import News
+from archweb_dev.main.utils import render_response
+from archweb_dev.main.models import News
from datetime import date
def view(request, newsid):
diff --git a/packages/models.py b/packages/models.py
deleted file mode 100644
index bce638df..00000000
--- a/packages/models.py
+++ /dev/null
@@ -1,94 +0,0 @@
-from django.db import models
-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
-
-class Category(models.Model):
- 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'
- 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"
-
-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'
-
- 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 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'
-
-# vim: set ts=4 sw=4 et:
-
diff --git a/packages/views.py b/packages/views.py
index 2b8f8b22..25bb342e 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -5,9 +5,9 @@ from django.template import Context, loader
from django.core import validators
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
-from archweb_dev.lib.utils import validate, render_response
from datetime import datetime
-from archweb_dev.packages.models import Package, PackageFile, Repo, Category
+from archweb_dev.main.utils import validate, render_response
+from archweb_dev.main.models import Package, PackageFile, Repo, Category
from django.core.exceptions import ObjectDoesNotExist
diff --git a/settings.py b/settings.py
index 7051f0ca..fc5f6e38 100644
--- a/settings.py
+++ b/settings.py
@@ -67,7 +67,7 @@ TEMPLATE_DIRS = (
# Set django's User stuff to use our profile model
# format is app.model
-AUTH_PROFILE_MODULE = 'devel.UserProfile'
+AUTH_PROFILE_MODULE = 'main.UserProfile'
INSTALLED_APPS = (
'django.contrib.auth',
@@ -75,6 +75,7 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
+ 'archweb_dev.main', # contains shared models and libs
'archweb_dev.news',
'archweb_dev.packages',
'archweb_dev.todolists',
diff --git a/todolists/models.py b/todolists/models.py
deleted file mode 100644
index ec24d5ed..00000000
--- a/todolists/models.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from django.db import models
-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
-
-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'
-
-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'),)
-
-# vim: set ts=4 sw=4 et:
-
diff --git a/todolists/views.py b/todolists/views.py
index cce92a6c..59dc5dbf 100644
--- a/todolists/views.py
+++ b/todolists/views.py
@@ -2,9 +2,8 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
-from archweb_dev.lib.utils import render_response
-from archweb_dev.todolists.models import Todolist, TodolistPkg
-from archweb_dev.packages.models import Package
+from archweb_dev.main.utils import render_response
+from archweb_dev.main.models import Todolist, TodolistPkg, Package
# FIXME: ugly hackery. http://code.djangoproject.com/ticket/3450
import django.db
diff --git a/wiki/models.py b/wiki/models.py
deleted file mode 100644
index 85f0726c..00000000
--- a/wiki/models.py
+++ /dev/null
@@ -1,19 +0,0 @@
-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'
-
- def editurl(self):
- return "/wiki/edit/" + self.title + "/"
-
- def __repr__(self):
- return self.title
-
-# vim: set ts=4 sw=4 et:
-
diff --git a/wiki/templatetags/wikitags.py b/wiki/templatetags/wikitags.py
index c8c1cd38..da662e8a 100644
--- a/wiki/templatetags/wikitags.py
+++ b/wiki/templatetags/wikitags.py
@@ -1,6 +1,6 @@
from django.template import Library
from django.conf import settings
-from archweb_dev.lib import markdown
+from archweb_dev.main import markdown
import re
register = Library()
diff --git a/wiki/views.py b/wiki/views.py
index 796f5f98..4c9f732f 100644
--- a/wiki/views.py
+++ b/wiki/views.py
@@ -3,8 +3,8 @@
#
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
-from archweb_dev.lib.utils import render_response
-from archweb_dev.wiki.models import Wikipage
+from archweb_dev.main.utils import render_response
+from archweb_dev.main.models import Wikipage
@login_required
def index(request):