aboutsummaryrefslogtreecommitdiff
path: root/chishop/djangopypi/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chishop/djangopypi/models.py')
-rw-r--r--chishop/djangopypi/models.py119
1 files changed, 119 insertions, 0 deletions
diff --git a/chishop/djangopypi/models.py b/chishop/djangopypi/models.py
new file mode 100644
index 0000000..d66f5c8
--- /dev/null
+++ b/chishop/djangopypi/models.py
@@ -0,0 +1,119 @@
1""" models.py
2
3Copyright (c) 2009, Ask Solem
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 * Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14
15Neither the name of Ask Solem nor the names of its contributors may be used
16to endorse or promote products derived from this software without specific
17prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
23BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29POSSIBILITY OF SUCH DAMAGE.
30
31"""
32
33import os
34from django.db import models
35from django.utils.translation import ugettext_lazy as _
36
37OS_NAMES = (
38 ("aix", "AIX"),
39 ("beos", "BeOS"),
40 ("debian", "Debian Linux"),
41 ("dos", "DOS"),
42 ("freebsd", "FreeBSD"),
43 ("hpux", "HP/UX"),
44 ("mac", "Mac System x."),
45 ("macos", "MacOS X"),
46 ("mandrake", "Mandrake Linux"),
47 ("netbsd", "NetBSD"),
48 ("openbsd", "OpenBSD"),
49 ("qnx", "QNX"),
50 ("redhat", "RedHat Linux"),
51 ("solaris", "SUN Solaris"),
52 ("suse", "SuSE Linux"),
53 ("yellowdog", "Yellow Dog Linux"),
54)
55
56ARCHITECTURES = (
57 ("alpha", "Alpha"),
58 ("hppa", "HPPA"),
59 ("ix86", "Intel"),
60 ("powerpc", "PowerPC"),
61 ("sparc", "Sparc"),
62 ("ultrasparc", "UltraSparc"),
63)
64
65
66class Classifier(models.Model):
67 name = models.CharField(max_length=255, unique=True)
68
69 class Meta:
70 verbose_name = _(u"classifier")
71 verbose_name_plural = _(u"classifiers")
72
73 def __unicode__(self):
74 return self.name
75
76
77class Project(models.Model):
78 name = models.CharField(max_length=255, unique=True)
79 license = models.CharField(max_length=255, blank=True)
80 metadata_version = models.CharField(max_length=64, default=1.0)
81 author = models.CharField(max_length=128, blank=True)
82 home_page = models.URLField(verify_exists=False, blank=True, null=True)
83 download_url = models.URLField(verify_exists=False, blank=True, null=True)
84 summary = models.TextField(blank=True)
85 description = models.TextField(blank=True)
86 author_email = models.CharField(max_length=255, blank=True)
87 classifiers = models.ManyToManyField(Classifier)
88
89 class Meta:
90 verbose_name = _(u"project")
91 verbose_name_plural = _(u"projects")
92
93 def __unicode__(self):
94 return self.name
95
96
97class Release(models.Model):
98 version = models.CharField(max_length=128)
99 distribution = models.FileField(upload_to="dists")
100 dist_md5sum = models.CharField(max_length=255, blank=True)
101 platform = models.CharField(max_length=255, blank=True)
102 signature = models.CharField(max_length=128, blank=True)
103 project = models.ForeignKey(Project, related_name="releases")
104
105 class Meta:
106 unique_together = ('version', 'platform')
107 verbose_name = _(u"release")
108 verbose_name_plural = _(u"releases")
109
110 def __unicode__(self):
111 return self.version
112
113 @property
114 def filename(self):
115 return os.path.basename(self.distribution.name)
116
117 @property
118 def path(self):
119 return self.distribution.name