Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[djangoproject.com] updated website to use Django 1.0.

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@9073 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 640482a883e95b346af6157c8f27a5f21d354c89 1 parent 5ab5acd
jacob authored
Showing with 165 additions and 171 deletions.
  1. +17 −0 django_website/apps/aggregator/admin.py
  2. +6 −13 django_website/apps/aggregator/models.py
  3. +6 −0 django_website/apps/blog/admin.py
  4. +24 −11 django_website/apps/blog/models.py
  5. +1 −1  django_website/apps/contact/forms.py
  6. +2 −2 django_website/apps/docs/models.py
  7. +2 −2 django_website/settings.py
  8. +2 −4 django_website/templates/blog/entry_archive.html
  9. +2 −2 django_website/templates/blog/entry_archive_day.html
  10. +2 −2 django_website/templates/blog/entry_archive_month.html
  11. +6 −6 django_website/templates/blog/entry_detail.html
  12. +1 −1  django_website/templates/blog/entry_snippet.html
  13. +1 −0  django_website/templates/comments/base.html
  14. 0  django_website/templates/comments/{freecomment_list.html → comment_list.html}
  15. +22 −0 django_website/templates/comments/form.html
  16. +0 −45 django_website/templates/comments/free_preview.html
  17. +0 −10 django_website/templates/comments/freeform.html
  18. +7 −0 django_website/templates/comments/preview.html
  19. +1 −16 django_website/templates/contact/foundation.html
  20. 0  django_website/templates/{flatpages → }/homepage.html
  21. +31 −45 django_website/templates/registration/registration_form.html
  22. +16 −0 django_website/upgrade/upgrade-to-1.0.sql
  23. +12 −7 django_website/urls.py
  24. +1 −1  djangodocs/forms.py
  25. +2 −2 djangodocs/templates/docs/doc.html
  26. +1 −1  djangodocs/templates/docs/search_form.html
View
17 django_website/apps/aggregator/admin.py
@@ -0,0 +1,17 @@
+from django.contrib import admin
+from django_website.apps.aggregator.models import Feed, FeedItem
+
+admin.site.register(Feed,
+ list_display = ["title", "public_url", "is_defunct"],
+ list_filter = ["is_defunct"],
+ ordering = ["title"],
+ search_fields = ["title", "public_url"],
+ list_per_page = 500,
+)
+
+admin.site.register(FeedItem,
+ list_display = ['title', 'feed', 'date_modified'],
+ list_filter = ['feed'],
+ search_fields = ['feed__title', 'feed__public_url', 'title'],
+ date_heirarchy = ['date_modified'],
+)
View
19 django_website/apps/aggregator/models.py
@@ -1,31 +1,24 @@
from django.db import models
class Feed(models.Model):
- title = models.CharField(maxlength=500)
- feed_url = models.URLField(unique=True, maxlength=500)
- public_url = models.URLField(maxlength=500)
+ title = models.CharField(max_length=500)
+ feed_url = models.URLField(unique=True, max_length=500)
+ public_url = models.URLField(max_length=500)
is_defunct = models.BooleanField()
class Meta:
db_table = 'aggregator_feeds'
- class Admin:
- list_display = ["title", "public_url", "is_defunct"]
- list_filter = ["is_defunct"]
- ordering = ["title"]
- search_fields = ["title", "public_url"]
- list_per_page = 500
-
def __unicode__(self):
return self.title
class FeedItem(models.Model):
feed = models.ForeignKey(Feed)
- title = models.CharField(maxlength=500)
- link = models.URLField(maxlength=500)
+ title = models.CharField(max_length=500)
+ link = models.URLField(max_length=500)
summary = models.TextField(blank=True)
date_modified = models.DateTimeField()
- guid = models.CharField(maxlength=500, unique=True, db_index=True)
+ guid = models.CharField(max_length=500, unique=True, db_index=True)
class Meta:
db_table = 'aggregator_feeditems'
View
6 django_website/apps/blog/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+from django_website.apps.blog.models import Entry
+
+admin.site.register(Entry,
+ list_display = ('pub_date', 'headline', 'author'),
+)
View
35 django_website/apps/blog/models.py
@@ -1,14 +1,18 @@
+import akismet
import datetime
+from django.conf import settings
from django.db import models
-from comment_utils.moderation import CommentModerator, moderator
+from django.contrib.sites.models import Site
+from django.contrib.comments.signals import comment_was_posted
+from django.utils.encoding import smart_str
class Entry(models.Model):
pub_date = models.DateTimeField()
slug = models.SlugField(unique_for_date='pub_date')
- headline = models.CharField(maxlength=200)
+ headline = models.CharField(max_length=200)
summary = models.TextField(help_text="Use raw HTML.")
body = models.TextField(help_text="Use raw HTML.")
- author = models.CharField(maxlength=100)
+ author = models.CharField(max_length=100)
class Meta:
db_table = 'blog_entries'
@@ -16,9 +20,6 @@ class Meta:
ordering = ('-pub_date',)
get_latest_by = 'pub_date'
- class Admin:
- list_display = ('pub_date', 'headline', 'author')
-
def __unicode__(self):
return self.headline
@@ -30,8 +31,20 @@ def comments_enabled(self):
delta = datetime.datetime.now() - self.pub_date
return delta.days < 60
-class EntryModerator(CommentModerator):
- akismet = True
- enable_field = "comments_enabled"
-
-moderator.register(Entry, EntryModerator)
+def moderate_comment(sender, comment, request, **kwargs):
+ ak = akismet.Akismet(
+ key = settings.AKISMET_API_KEY,
+ blog_url = 'http://%s/' % Site.objects.get_current().domain
+ )
+ data = {
+ 'user_ip': request.META.get('REMOTE_ADDR', '127.0.0.1'),
+ 'user_agent': request.META.get('HTTP_USER_AGENT', ''),
+ 'referrer': request.META.get('HTTP_REFERRER', ''),
+ 'comment_type': 'comment',
+ 'comment_author': smart_str(comment.user_name),
+ }
+ if ak.comment_check(smart_str(comment.comment), data=data, build_data=True):
+ comment.is_public = False
+ comment.save()
+
+comment_was_posted.connect(moderate_comment)
View
2  django_website/apps/contact/forms.py
@@ -1,5 +1,5 @@
import textwrap
-from django import newforms as forms
+from django import forms
from contact_form.forms import AkismetContactForm
attrs = {'class': 'required'}
View
4 django_website/apps/docs/models.py
@@ -1,8 +1,8 @@
from django.db import models
class DocumentRelease(models.Model):
- version = models.CharField(maxlength=20, unique=True)
- repository_path = models.CharField(maxlength=50, help_text="(i.e. 'tags/releases/0.95' or 'branches/0.95-bugfixes')")
+ version = models.CharField(max_length=20, unique=True)
+ repository_path = models.CharField(max_length=50, help_text="(i.e. 'tags/releases/0.95' or 'branches/0.95-bugfixes')")
release_date = models.DateField()
class Meta:
View
4 django_website/settings.py
@@ -18,6 +18,7 @@
PREPEND_WWW = False
CACHE_BACKEND = "dummy:///"
DJANGO_SVN_ROOT = "http://code.djangoproject.com/svn/django/"
+ ADMIN_MEDIA_PREFIX = '/media/'
else:
DEBUG = False
PREPEND_WWW = True
@@ -25,6 +26,7 @@
CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
TEMPLATE_DIRS = ['/home/djangoproject.com/django_website/templates']
DJANGO_SVN_ROOT = "file:///home/svn/django/django/"
+ ADMIN_MEDIA_PREFIX = 'http://media.djangoproject.com/admin/'
SITE_ID = 1
ROOT_URLCONF = 'django_website.urls'
@@ -43,9 +45,7 @@
'django_website.apps.docs',
'django_website.apps.aggregator',
'registration',
- 'comment_utils',
)
-ADMIN_MEDIA_PREFIX = 'http://media.djangoproject.com/admin/'
MEDIA_ROOT = "/home/html/djangoproject.com/m/"
MEDIA_URL = "http://www.djangoproject.com.com/m/"
View
6 django_website/templates/blog/entry_archive.html
@@ -2,13 +2,11 @@
{% block content %}
-{% load comments comment_utils %}
-
<h1>Latest entries</h1>
{% for object in latest %}
- <h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
- {{ object.body }}
+ <h2><a href="{{ object.get_absolute_url }}">{{ object.headline|safe }}</a></h2>
+ {{ object.body|safe }}
<p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p>
{% endfor %}
View
4 django_website/templates/blog/entry_archive_day.html
@@ -7,9 +7,9 @@
<h1>{{ day|date:"F j" }} archive</h1>
{% for object in object_list %}
-<h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
+<h2><a href="{{ object.get_absolute_url }}">{{ object.headline|safe }}</a></h2>
<p class="small date">{{ object.pub_date|date:"F j, Y" }}</p>
-{{ object.body }}
+{{ object.body|safe }}
{% endfor %}
View
4 django_website/templates/blog/entry_archive_month.html
@@ -7,9 +7,9 @@
<h1>{{ month|date:"F" }} archive</h1>
{% for object in object_list %}
-<h2><a href="{{ object.get_absolute_url }}">{{ object.headline }}</a></h2>
+<h2><a href="{{ object.get_absolute_url }}">{{ object.headline|safe }}</a></h2>
<p class="small date">{{ object.pub_date|date:"F j, Y" }}</p>
-{{ object.body }}
+{{ object.body|safe }}
{% endfor %}
View
12 django_website/templates/blog/entry_detail.html
@@ -4,26 +4,26 @@
{% block content %}
-<h1>{{ object.headline }}</h1>
-{{ object.body }}
+<h1>{{ object.headline|safe }}</h1>
+{{ object.body|safe }}
<p class="date small">Posted by <strong>{{ object.author }}</strong> on {{ object.pub_date|date:"F j, Y" }}</p>
-{% load comments comment_utils %}
-{% get_public_free_comment_list for blog.entry object.id as comment_list %}
+{% load comments %}
+{% get_comment_list for blog.entry object.id as comment_list %}
<div id="content-secondary">
<h2 id="comments">Comments</h2>
{% for comment in comment_list %}
<div class="comment" id="c{{ comment.id }}">
- <h3>{{ comment.person_name|escape }} <span class="small quiet">{{ comment.submit_date|date:"F j, Y" }} at {{ comment.submit_date|date:"P" }}</span></h3>
+ <h3>{{ comment.user_name|escape }} <span class="small quiet">{{ comment.submit_date|date:"F j, Y" }} at {{ comment.submit_date|date:"P" }}</span></h3>
{{ comment.comment|escape|urlizetrunc:"40"|linebreaks }}
</div>
{% endfor %}
{% if object.comments_enabled %}
<h2>Post a comment</h2>
-{% free_comment_form for blog.entry object.id %}
+{% render_comment_form for blog.entry object.id %}
{% else %}
<h2>Comments are closed</h2>
<p>To prevent spam, comments are no longer allowed after sixty days.</p>
View
2  django_website/templates/blog/entry_snippet.html
@@ -1,6 +1,6 @@
{% for e in entries %}
<h3><a href="{{ e.get_absolute_url }}">{{ e.headline }}</a></h3>
<p class="date">by <strong>{{ e.author }}</strong> on {{ e.pub_date|date:"M. j, Y" }}</p>
- {{ e.summary }}
+ {{ e.summary|safe }}
<p class="more"><a href="{{ e.get_absolute_url }}">Read more</a></p>
{% endfor %}
View
1  django_website/templates/comments/base.html
@@ -0,0 +1 @@
+{% extends "base_weblog.html" %}
View
0  ..._website/templates/comments/freecomment_list.html → django_website/templates/comments/comment_list.html
File renamed without changes
View
22 django_website/templates/comments/form.html
@@ -0,0 +1,22 @@
+{% load comments %}
+<form action="{% comment_form_target %}" method="post" class="wide">
+ {% for field in form %}
+ {% if field.is_hidden %}
+ {{ field }}
+ {% else %}
+ <p
+ {% if field.errors %} class="error"{% endif %}
+ {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+ {{ field.label_tag }}
+ {% if field.errors %}
+ <p class="errors">{{ field.errors.as_text }}</p>
+ {% endif %}
+ {{ field }}
+ </p>
+ {% endif %}
+ {% endfor %}
+ <p class="submit">
+ <input type="submit" name="submit" class="submit-post" value="Post" />
+ <input type="submit" name="submit" class="submit-preview" value="Preview" />
+ </p>
+</form>
View
45 django_website/templates/comments/free_preview.html
@@ -1,45 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}Preview comment{% endblock %}
-
-{% block content %}
-
-<style type="text/css">
-#comments textarea { width: 380px; font: 12px verdana,sans-serif; }
-</style>
-
-<h1>Preview your comment</h1>
-
-<form action="../postfree/" method="post">
-
-{% if comment_form.has_errors %}
- <p><strong style="color: red;">Please correct the following errors.</strong></p>
-{% else %}
- <div class="comment">
- {{ comment.comment|escape|urlizetrunc:"40"|linebreaks }}
- <p class="date small">Posted by <strong>{{ comment.person_name|escape }}</strong></p>
- </div>
-
- <p><input type="submit" name="post" value="Post public comment" /></p>
-
- <h1>Or edit it again</h1>
-{% endif %}
-
-{% if comment_form.person_name.errors %}
- {{ comment_form.person_name.html_error_list }}
-{% endif %}
-
-<p><label for="id_person_name">Your name:</label> {{ comment_form.person_name }}</p>
-
-{% if comment_form.comment.errors %}
-{{ comment_form.comment.html_error_list }}
-{% endif %}
-
-<p><label for="id_person_name">Comment:</label><br />{{ comment_form.comment }}</p>
-<input type="hidden" name="options" value="{{ options }}" />
-<input type="hidden" name="target" value="{{ target }}" />
-<input type="hidden" name="gonzo" value="{{ hash }}" />
-<p><input type="submit" name="preview" value="Preview revised comment" /></p>
-</form>
-
-{% endblock %}
View
10 django_website/templates/comments/freeform.html
@@ -1,10 +0,0 @@
-{% if display_form %}
-<form action="/comments/postfree/" method="post">
-<p>Your name: <input type="text" id="id_person_name" name="person_name" /></p>
-<p>Comment:<br /><textarea name="comment" id="id_comment" rows="10" cols="60"></textarea></p>
-<input type="hidden" name="options" value="{{ options }}" />
-<input type="hidden" name="target" value="{{ target }}" />
-<input type="hidden" name="gonzo" value="{{ hash }}" />
-<p><input type="submit" name="preview" value="Preview comment" /></p>
-</form>
-{% endif %}
View
7 django_website/templates/comments/preview.html
@@ -0,0 +1,7 @@
+{% extends "comments/base.html" %}
+
+{% block title %}Preview your comment{% endblock %}
+
+{% block content %}
+ {% include "comments/form.html" %}
+{% endblock %}
View
17 django_website/templates/contact/foundation.html
@@ -2,24 +2,9 @@
{% block title %}Contact the Django Software Foundation{% endblock %}
-{% block extrahead %}
- {{ block.super }}
- <style type="text/css" media="screen">
- form.contact label { display: block; font-weight: bold; margin-top: 1.5em; margin-bottom: 0;}
- form.contact label span { font-weight: normal; color: #555; }
- form.contact input,
- form.contact textarea,
- form.contact select { width: 99%; padding: 1px; }
- form.contact p { margin: 0; }
- form.contact p.submit { text-align: right; margin-top: 1em; margin-right: 0;}
- form.contact p.submit input { width: 10em; font-size: 1.5em; }
- form.contact p.errors { margin: 0; padding: 0; font-weight: bold; color: red; }
- </style>
-{% endblock %}
-
{% block content %}
<h1>Contact the Django Software Foundation</h1>
-<form action="." method="post" accept-charset="utf-8" class="contact">
+<form action="." method="post" accept-charset="utf-8" class="wide">
<p>
<label for="id_name">Your name:</label>
{% if form.name.errors %}<p class="errors">{{ form.name.errors.as_text }}</p>{% endif %}
View
0  django_website/templates/flatpages/homepage.html → django_website/templates/homepage.html
File renamed without changes
View
76 django_website/templates/registration/registration_form.html
@@ -5,55 +5,41 @@
{% block content %}
{% if form.errors %}
- <p class="error">Please correct the errors below: {{ form.non_field_errors }}</p>
+ <p class="errors">Please correct the errors below: {{ form.non_field_errors }}</p>
{% endif %}
<h1>Create an account</h1>
- <form method="post" action="">
- <dl>
- <dt>
- <label for="id_username">Username:</label>
- </dt>
- <dd>
- {{ form.username }}
- {% if form.username.errors %}
- <span class="error">* {{ form.username.errors|join:", " }}</span>
- {% endif %}
- </dd>
-
- <dt>
- <label for="id_email">Email address:</label>
- </dt>
- <dd>
- {{ form.email }}
- {% if form.email.errors %}
- <span class="error">* {{ form.email.errors|join:", " }}</span>
- {% endif %}
- </dd>
-
- <dt>
- <label for="id_password1">Password:</label>
- </dt>
- <dd>
- {{ form.password1 }}
- {% if form.password1.errors %}
- <span class="error">* {{ form.password2.errors|join:", " }}</span>
- {% endif %}
- </dd>
-
- <dt>
- <label for="id_password2">Password (type again to catch typos):</label>
- </dt>
- <dd>
- {{ form.password2 }}
- {% if form.password2.errors %}
- <span class="error">* {{ form.password2.errors|join:", " }}</span>
- {% endif %}
- </dd>
-
- <dt><input type="submit" value="Register" /></dt>
- </dl>
+ <form method="post" action="" class="wide">
+ <p>
+ <label for="id_username">Username:</label>
+ {% if form.username.errors %}
+ <p class="errors">{{ form.username.errors.as_text }}</p>
+ {% endif %}
+ {{ form.username }}
+ </p>
+ <p>
+ <label for="id_email">Email address:</label>
+ {% if form.email.errors %}
+ <p class="errors">{{ form.email.errors.as_text }}</p>
+ {% endif %}
+ {{ form.email }}
+ </p>
+ <p>
+ <label for="id_password1">Password:</label>
+ {% if form.password1.errors %}
+ <p class="errors">{{ form.password1.errors.as_text }}</p>
+ {% endif %}
+ {{ form.password1 }}
+ </p>
+ <p>
+ <label for="id_password2">Password (type again to catch typos):</label>
+ {% if form.password2.errors %}
+ <p class="errors">{{ form.password2.errors.as_text }}</p>
+ {% endif %}
+ {{ form.password2 }}
+ </p>
+ <p class="submit"><input type="submit" value="Register &rarr;"></p>
</form>
{% endblock %}
View
16 django_website/upgrade/upgrade-to-1.0.sql
@@ -0,0 +1,16 @@
+begin;
+delete from django_admin_log;
+delete from comments_freecomment where content_type_id = 13;
+
+INSERT INTO django_comments
+ (content_type_id, object_pk, site_id, user_name, user_email, user_url,
+ comment, submit_date, ip_address, is_public, is_removed)
+SELECT
+ content_type_id, object_id, site_id, person_name, '', '', comment,
+ submit_date, ip_address, is_public, approved
+FROM comments_freecomment;
+
+drop table comments_freecomment;
+drop table comments_comment cascade;
+
+commit;
View
19 django_website/urls.py
@@ -1,6 +1,8 @@
+from django.conf import settings
from django.conf.urls.defaults import *
-from django.contrib.comments.feeds import LatestFreeCommentsFeed
-from django.contrib.comments.models import FreeComment
+from django.contrib import admin
+from django.contrib.comments.feeds import LatestCommentFeed
+from django.contrib.comments.models import Comment
from django.contrib.sitemaps import views as sitemap_views
from django_website.apps.aggregator.feeds import CommunityAggregatorFeed
from django_website.apps.aggregator.models import FeedItem
@@ -9,7 +11,7 @@
from django.views.decorators.cache import cache_page
comments_info_dict = {
- 'queryset': FreeComment.objects.filter(is_public=True),
+ 'queryset': Comment.objects.filter(is_public=True).order_by('-submit_date'),
'paginate_by': 15,
}
@@ -20,7 +22,7 @@
feeds = {
'weblog': WeblogEntryFeed,
- 'comments': LatestFreeCommentsFeed,
+ 'comments': LatestCommentFeed,
'community': CommunityAggregatorFeed,
}
@@ -30,11 +32,11 @@
}
urlpatterns = patterns('',
- (r'freenode\.9xJY7YIUWtwn\.html', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
+ (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'homepage.html'}),
(r'^accounts/', include('django_website.apps.accounts.urls')),
- (r'^admin/', include('django.contrib.admin.urls')),
+ (r'^admin/(.*)', admin.site.root),
(r'^comments/$', 'django.views.generic.list_detail.object_list', comments_info_dict),
- (r'^comments/', include('django.contrib.comments.urls.comments')),
+ (r'^comments/', include('django.contrib.comments.urls')),
(r'^community/$', 'django.views.generic.list_detail.object_list', aggregator_info_dict),
(r'^contact/', include('django_website.apps.contact.urls')),
(r'^documentation/', include('django_website.apps.docs.urls')),
@@ -42,5 +44,8 @@
(r'^rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
(r'^sitemap.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6), {'sitemaps': sitemaps}),
(r'^weblog/', include('django_website.apps.blog.urls')),
+ (r'^freenode\.9xJY7YIUWtwn\.html$', 'django.views.generic.simple.direct_to_template', {'template': 'freenode_tmp.html'}),
(r'', include('django.contrib.flatpages.urls')),
)
+
+admin.autodiscover()
View
2  djangodocs/forms.py
@@ -1,4 +1,4 @@
-from django import newforms as forms
+from django import forms
AS_Q_CHOICES = (
('more:dev_docs', 'Latest'),
View
4 djangodocs/templates/docs/doc.html
@@ -38,7 +38,7 @@
{% block content %}
{% block body %}
- {{ doc.body }}
+ {{ doc.body|safe }}
{% endblock %}
<div id="content-secondary">
@@ -75,7 +75,7 @@ <h2 id="comments">Questions/Feedback</h2>
{% block toc-wrapper %}
<h2>Contents</h2>
{% block toc %}
- {{ doc.toc }}
+ {{ doc.toc|safe }}
{% endblock %}
{% endblock %}
View
2  djangodocs/templates/docs/search_form.html
@@ -9,4 +9,4 @@
{{ form.as_q }}
</div>
</form>
-<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form={{ search_form_id|escape }}&lang={{ lang|escape }}"></script>
+<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form={{ search_form_id|escape }}&amp;lang={{ lang|escape }}"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.