Skip to content
Browse files

Add Django admin.

  • Loading branch information...
1 parent 808ba0b commit d8001474dd5b41491efc6176a0cd81b249f9eff2 @carljm carljm committed
View
0 ...ler/admin/management/commands/__init__.py → assets/.keep
File renamed without changes.
View
0 ...e/controller/admin/management/__init__.py → spade/controller/management/__init__.py
File renamed without changes.
View
0 spade/controller/admin/__init__.py → ...ontroller/management/commands/__init__.py
File renamed without changes.
View
0 ...er/admin/management/commands/crawllist.py → ...ntroller/management/commands/crawllist.py
File renamed without changes.
View
0 ...ller/admin/management/commands/scraper.py → ...controller/management/commands/scraper.py
File renamed without changes.
View
0 ...r/admin/management/commands/useragents.py → ...troller/management/commands/useragents.py
File renamed without changes.
View
13 spade/model/admin.py
@@ -0,0 +1,13 @@
+from django.contrib import admin
+
+from . import models
+
+
+admin.site.register(models.Batch)
+admin.site.register(models.SiteScan)
+admin.site.register(models.URLScan)
+admin.site.register(models.URLContent)
+admin.site.register(models.LinkedCSS)
+admin.site.register(models.LinkedJS)
+admin.site.register(models.UserAgent)
+admin.site.register(models.CrawlList)
View
31 spade/model/models.py
@@ -10,12 +10,21 @@ class Batch(models.Model):
kickoff_time = models.DateTimeField("When crawl started")
finish_time = models.DateTimeField("When crawl ended")
+ def __unicode__(self):
+ return u"Batch started at {0}".format(self.kickoff_time)
+
+ class Meta:
+ verbose_name_plural = u"Batches"
+
class SiteScan(models.Model):
"""An individual site scanned."""
batch = models.ForeignKey(Batch, db_index=True)
site_url = models.CharField(max_length=200)
+ def __unicode__(self):
+ return self.site_url
+
class URLScan(models.Model):
"""
@@ -30,6 +39,9 @@ class URLScan(models.Model):
page_url = models.CharField(max_length=200)
timestamp = models.DateTimeField("timestamp")
+ def __unicode__(self):
+ return self.page_url
+
class UserAgent(models.Model):
"""A user-agent string we will use for scanning."""
@@ -54,6 +66,10 @@ class URLContent(models.Model):
headers = models.FileField(
max_length=500, upload_to='crawls/headers/%Y/%m/%d')
+ def __unicode__(self):
+ return u"'{0}' scanned with '{1}'".format(
+ self.url_scan, self.user_agent)
+
class LinkedCSS(models.Model):
"""A single linked CSS file."""
@@ -61,6 +77,12 @@ class LinkedCSS(models.Model):
raw_css = models.FileField(
max_length=500, upload_to='crawls/css/%Y/%m/%d')
+ def __unicode__(self):
+ return self.raw_css.name
+
+ class Meta:
+ verbose_name_plural = "Linked CSS"
+
class LinkedJS(models.Model):
"""A single linked JS file."""
@@ -68,7 +90,16 @@ class LinkedJS(models.Model):
raw_js = models.FileField(
max_length=500, upload_to='crawls/js/%Y/%m/%d')
+ def __unicode__(self):
+ return self.raw_js.name
+
+ class Meta:
+ verbose_name_plural = "Linked JS"
+
class CrawlList(models.Model):
"""A site URL to be crawled."""
url = models.CharField(max_length=200, unique=True)
+
+ def __unicode__(self):
+ return self.url
View
22 spade/settings/base.py
@@ -13,9 +13,10 @@
TEMPLATE_DEBUG = DEBUG
-ADMINS = (
+ADMINS = [
("Sam Liu", "sliu@mozilla.com"),
-)
+ ("Carl Meyer", "cmeyer@mozilla.com"),
+]
MANAGERS = ADMINS
@@ -123,18 +124,15 @@
]
INSTALLED_APPS = (
- #'django.contrib.auth',
- #'django.contrib.contenttypes',
- #'django.contrib.sessions',
- #'django.contrib.sites',
- #'django.contrib.messages',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
'django.contrib.staticfiles',
- 'spade.controller.admin',
+ 'django.contrib.admin',
+ 'spade.controller',
'spade.model',
- # Uncomment the next line to enable the admin:
- # 'django.contrib.admin',
- # Uncomment the next line to enable admin documentation:
- # 'django.contrib.admindocs',
)
# A sample logging configuration. The only tangible logging
View
26 spade/settings/local.sample.py
@@ -5,7 +5,6 @@
Copy local.sample.py to local.py and modify as needed.
"""
-
# Local settings (overrides)
DATABASES = {
@@ -22,3 +21,28 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'CHANGETHISFJKDFJDKFJDK#%^&JDKJDKFDK@K$%^KJ#K%J^K^JK@CHANGETHIS'
+# Settings below here don't need to be changed if the defaults suffice
+
+# Change this to store scraped files somewhere other than the local filesystem
+# (e.g. the S3 backend in the django-storages project). The MEDIA_* settings
+# below are only relevant if FileSystemStorage (the default) is used.
+#DEFAULT_FILE_STORAGE = "django.core.files.storage.FileSystemStorage"
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+#MEDIA_ROOT = join(BASE_PATH, 'media')
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+#MEDIA_URL = '/media/'
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+#STATIC_ROOT = join(BASE_PATH, 'assets')
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+#STATIC_URL = '/static/'
View
16 spade/view/urls.py
@@ -1,18 +1,14 @@
from django.conf.urls import patterns, include, url
+from django.conf.urls.static import static
+from django.conf import settings
-# Uncomment the next two lines to enable the admin:
-# from django.contrib import admin
-# admin.autodiscover()
+from django.contrib import admin
+admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'spade.view.views.home', name='home'),
- # url(r'^spade/', include('spade.foo.urls')),
- # Uncomment the admin/doc line below to enable admin documentation:
- # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ url(r'^admin/', include(admin.site.urls)),
- # Uncomment the next line to enable the admin:
- # url(r'^admin/', include(admin.site.urls)),
-
-)
+) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0 comments on commit d800147

Please sign in to comment.
Something went wrong with that request. Please try again.