Skip to content

Commit

Permalink
update django to 1.5.
Browse files Browse the repository at this point in the history
Related to #46.
  • Loading branch information
andrewsmedina committed Mar 12, 2013
1 parent d2a32db commit d4a82ec
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 41 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==1.3.1
Django==1.5
python-twitter==0.8.2
markdown==2.0.3
git+git://github.com/dominno/django-moderation.git
Expand Down
2 changes: 1 addition & 1 deletion src/djangobrasil/aggregator/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# See LICENSE file

from django.contrib.syndication.feeds import Feed
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
from djangobrasil.aggregator.models import FeedItem

Expand Down
4 changes: 2 additions & 2 deletions src/djangobrasil/aggregator/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class FeedForm(forms.ModelForm):
title = forms.CharField(label="Título", max_length=50)
email = forms.EmailField(label="E-mail")
feed_url = forms.URLField(label="URL Feed", verify_exists=False)
public_url = forms.URLField(label="URL Pública",verify_exists=False)
feed_url = forms.URLField(label="URL Feed")
public_url = forms.URLField(label="URL Pública")

class Meta:
model = Feed
2 changes: 1 addition & 1 deletion src/djangobrasil/blog/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from django.contrib.syndication.feeds import Feed
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
from djangobrasil.blog.models import Entry

Expand Down
22 changes: 8 additions & 14 deletions src/djangobrasil/blog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@


from django.conf.urls.defaults import *
from djangobrasil.blog.models import Entry

from .models import Entry
import views

info_dict = {
'queryset': Entry.published,
'date_field': 'pub_date',
}


urlpatterns = patterns(
'django.views.generic.date_based',
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
'object_detail', dict(info_dict, slug_field='slug', month_format='%m')),
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{1,2})/$', 'archive_day', dict(info_dict, month_format='%m')),
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/$', 'archive_month', dict(info_dict, month_format='%m')),
(r'^(?P<year>\d{4})/$', 'archive_year', info_dict),
(r'^/?$', 'archive_index', dict(info_dict, num_latest=5)),
urlpatterns = patterns('django.views.generic.date_based',
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$', views.DateDetail.as_view()),
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/(?P<day>\d{1,2})/$', views.DayArchive.as_view()),
(r'^(?P<year>\d{4})/(?P<month>[0-9]{2})/$', views.MonthArchive.as_view()),
(r'^(?P<year>\d{4})/$', views.YearArchive.as_view()),
(r'^$', views.Index.as_view()),
)
33 changes: 33 additions & 0 deletions src/djangobrasil/blog/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.views.generic import dates

from djangobrasil.blog.models import Entry


class Index(dates.ArchiveIndexView):
queryset = Entry.published
date_field = "pub_date"
num_latest = 5


class YearArchive(dates.YearArchiveView):
queryset = Entry.published
date_field = "pub_date"


class MonthArchive(dates.MonthArchiveView):
queryset = Entry.published
date_field = "pub_date"
month_format = '%m'


class DayArchive(dates.DayArchiveView):
queryset = Entry.published
date_field = "pub_date"
month_format = '%m'


class DateDetail(dates.DateDetailView):
queryset = Entry.published
date_field = "pub_date"
month_format = '%m'
slug_field = 'slug'
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ def setUp(self):
'message': 'bar'
}

def test_view_must_have_a_template_name(self):
response = self.client.get(reverse('contact'))
self.assertTrue(response.template_name)

def test_view_must_have_success_url(self):
self.assertEqual('/contato/', ContactView.success_url)

Expand Down
4 changes: 2 additions & 2 deletions src/djangobrasil/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
SECRET_KEY = 'set-this-in-your-settings_local.py!'

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
Expand Down
33 changes: 17 additions & 16 deletions src/djangobrasil/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from django.contrib import admin
from django.conf import settings
from django.views.generic import ListView
from django.views.generic.base import TemplateView
#from django.contrib.staticfiles.urls import staticfiles_urlpatterns

from djangobrasil.blog.models import Entry
from djangobrasil.blog.feeds import AtomLatestEntriesFeed, RssLatestEntriesFeed
from djangobrasil.aggregator.models import FeedItem
from djangobrasil.aggregator.feeds import RssCommunityAggregatorFeed, AtomCommunityAggregatorFeed
#from django.contrib.staticfiles.urls import staticfiles_urlpatterns

admin.autodiscover()

Expand All @@ -48,15 +51,15 @@
'comunidade': AtomCommunityAggregatorFeed,
}



aggregator_info_dict = {
'queryset': FeedItem.objects.select_related().filter(feed__accepted=True),
'paginate_by': 15,
}


urlpatterns = patterns(
'',

urlpatterns = patterns('',
# sitemaps
(r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': sitemaps}),
Expand All @@ -65,23 +68,25 @@
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),

# feeds
(r'^feeds/rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': rss_feeds}),
(r'^feeds/atom/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': atom_feeds}),
(r'^feeds/rss/comunidade/$', RssCommunityAggregatorFeed()),
(r'^feeds/atom/comunidade/$', AtomCommunityAggregatorFeed()),
(r'^feeds/rss/weblog/$', RssLatestEntriesFeed()),
(r'^feeds/atom/weblog/$', AtomLatestEntriesFeed()),

# admin
(r'^admin/', include(admin.site.urls)),

# home page
(r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'flatfiles/homepage.html'}),
(r'^$', TemplateView.as_view(template_name='flatfiles/homepage.html')),

# home page beta
(r'^beta/$', 'django.views.generic.simple.direct_to_template', {'template': 'flatfiles/beta.html'}),
(r'^beta/$', TemplateView.as_view(template_name='flatfiles/beta.html')),

# weblog
(r'^weblog/', include('djangobrasil.blog.urls')),

# comunidade
(r'^comunidade/$', 'django.views.generic.list_detail.object_list', aggregator_info_dict),
(r'^comunidade/$', ListView.as_view(queryset=FeedItem.objects.select_related().filter(feed__accepted=True), paginate_by=15)),

#solicitacao-de-feeds
(r'^participe-dos-feeds/', 'djangobrasil.aggregator.views.participe_dos_feeds'),
Expand All @@ -94,17 +99,13 @@
)

if settings.DEBUG:
urlpatterns += patterns(
'',

urlpatterns += patterns('',
# static files
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),

(r'^404/$', 'django.views.generic.simple.direct_to_template',
{'template': '404.html'}),
(r'^404$', TemplateView.as_view(template_name='404.html')),

(r'^500/$', 'django.views.generic.simple.direct_to_template',
{'template': '500.html'}),
(r'^500$', TemplateView.as_view(template_name='500.html')),
)
#urlpatterns += staticfiles_urlpatterns()

0 comments on commit d4a82ec

Please sign in to comment.