GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: stuff for my site
Homepage: http://www.thescoop.org/docs
Clone URL: git://github.com/dwillis/thescoop.git
added db models
Derek Willis (author)
Wed Mar 19 20:43:51 -0700 2008
commit  30a1f25cc17eea959614cb432b6ac67afb691d13
tree    15031b4c6da58425c79bd74dd593e6d9f4e9fbc1
parent  e67a0b1211bb761dd4fc94d69516c5235b0d277f
0
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+This is the code for the Django apps on thescoop.org, including the Database of CAR Stories and a long-planned but undeveloped blog app.
0
\ No newline at end of file
...
110
111
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
0
@@ -110,3 +110,36 @@ class Story(models.Model):
0
     return self.dburl.split('.')[-1]
0
   class Meta:
0
     verbose_name_plural='Stories'
0
+
0
+class Application(models.Model):
0
+ name = = models.CharField(max_length=90)
0
+ slug = models.SlugField(prepopulate_from=('name',))
0
+
0
+ class Admin:
0
+ pass
0
+
0
+ def __str__(self):
0
+ return self.name
0
+
0
+ def get_absolute_url(self):
0
+ return "/dbs/app/%s/" % self.slug
0
+
0
+class Database(models.Model):
0
+ post_date = models.DateField(blank=True)
0
+ source = models.ForeignKey(Source)
0
+ url = models.URLField()
0
+ title = models.CharField(max_length=90)
0
+ slug = models.SlugField(prepopulate_from=('title',))
0
+ credit = models.ManyToManyField(Byline, filter_interface=models.VERTICAL, blank=True)
0
+ topic = models.ManyToManyField(Topic, null=True)
0
+ application = models.ForeignKey(Application)
0
+ description = models.TextField()
0
+
0
+ class Admin:
0
+ pass
0
+
0
+ def __str__(self):
0
+ return self.title
0
+
0
+ def get_absolute_url(self):
0
+ return "/dbs/%s/" % self.slug
0
\ No newline at end of file
...
1
2
 
 
3
4
5
...
125
126
127
128
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
...
 
 
1
2
3
4
5
...
125
126
127
 
 
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
0
@@ -1,5 +1,5 @@
0
-from thescoop.car.models import Byline, Datatype, Nation, Source, State, Story, Topic, Type
0
-from django.shortcuts import render_to_response, get_object_or_404
0
+from thescoop.car.models import Byline, Datatype, Nation, Source, State, Story, Topic, Type, Application, Database
0
+from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
0
 from django.http import Http404, HttpResponse, HttpResponseRedirect
0
 from django.contrib.syndication.feeds import Feed
0
 
0
@@ -125,5 +125,20 @@ def blog_feed(request):
0
   return HttpResponseRedirect('http://blog.thescoop.org/feed/')
0
 
0
 def blog_main(request):
0
- return HttpResponseRedirect('http://blog.thescoop.org/')
0
-
0
+ return HttpResponseRedirect('http://blog.thescoop.org/')
0
+
0
+def db_index(request):
0
+ recent_dbs = Database.objects.all().order_by('-post_date')[:5]
0
+ app_types = Applications.objects.all().order_by('name')
0
+ return render_to_response('db_index.html', {'recent_dbs': recent_dbs, 'app_types': app_types})
0
+
0
+def db_detail(request, slug):
0
+ db = get_object_or_404(Database, slug=slug)
0
+ credits = db.credit.all()
0
+ topics = db.topic.all()
0
+ return render_to_response('db_detail.html', {'database': db, 'credits': credits, 'topics': topics })
0
+
0
+def db_app(request, appslug):
0
+ app = get_object_or_404(Application, slug=appslug)
0
+ db_list = get_list_or_404(Database, application=app).order_by('-post_date')
0
+ return render_to_response('db_app.html', {'app': app, 'db_list': db_list })
0
\ No newline at end of file
...
1
2
 
3
4
5
...
9
10
11
 
 
 
 
 
 
 
 
12
13
14
...
1
 
2
3
4
5
...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -1,5 +1,5 @@
0
 from django.contrib.syndication.feeds import Feed
0
-from thescoop.car.models import Byline, Datatype, Nation, Source, State, Story, Topic, Type
0
+from thescoop.car.models import Byline, Datatype, Nation, Source, State, Story, Topic, Type, Database, Application
0
 
0
 class LatestEntries(Feed):
0
   title = "The Scoop DOCS Recent Stories Feed"
0
@@ -9,6 +9,14 @@ class LatestEntries(Feed):
0
   def items(self):
0
     return Story.objects.select_related().order_by('-postdate')[:10]
0
 
0
+class LatestDatabases(Feed):
0
+ title = "The Scoop Recent Databases Feed"
0
+ link = "/dbs/"
0
+ description = "Most recent databases posted"
0
+
0
+ def items(self):
0
+ return Database.objects.select_related().all().order_by('-post_date')[:10]
0
+
0
 class LatestBylines(Feed):
0
   title = "The Scoop DOCS Recent Bylines Feed"
0
   link = "/docs/"
...
58
59
60
 
 
 
 
61
62
63
...
58
59
60
61
62
63
64
65
66
67
0
@@ -58,6 +58,10 @@ urlpatterns = patterns('',
0
     (r'^docs/source/$', 'thescoop.car.views.source_main'),
0
     (r'^docs/source/(.*)/(\d+)/$', 'thescoop.car.views.source_by_year'),
0
     (r'^docs/source/(.*)/$', 'thescoop.car.views.source'),
0
+ (r'^dbs/$', 'thescoop.car.views.db_index'),
0
+ (r'^dbs/app/(?P<appslug>.*)/$', 'thescoop.car.views.db_app'),
0
+ (r'^dbs/(.*)/$', 'thescoop.car.views.db_detail'),
0
+
0
 
0
 
0
     (r'^docs/date/$', 'django.views.generic.date_based.archive_index', dict(info_dict, template_name='story_archive_index.html')),

Comments

    No one has commented yet.