From b7bb8ec0115e9c9928a0e3177db027b0586d14d6 Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Tue, 28 Jun 2011 10:46:05 -0400 Subject: [PATCH] Removed unnecessary foreign key evaluations from MultiView subclass urlpatterns and get_reverse_params(). --- philo/contrib/julian/models.py | 6 +++--- philo/contrib/penfield/models.py | 14 +++++++------- philo/contrib/waldo/models.py | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/philo/contrib/julian/models.py b/philo/contrib/julian/models.py index fd0a7c5..837675b 100644 --- a/philo/contrib/julian/models.py +++ b/philo/contrib/julian/models.py @@ -223,17 +223,17 @@ class CalendarView(FeedView): # or per-calendar-view basis. #url(r'^%s/(?P[\w-]+)' % self.location_permalink_base, ...) - if self.tag_archive_page: + if self.tag_archive_page_id: urlpatterns += patterns('', url(r'^%s$' % self.tag_permalink_base, self.tag_archive_view, name='tag_archive') ) - if self.owner_archive_page: + if self.owner_archive_page_id: urlpatterns += patterns('', url(r'^%s$' % self.owner_permalink_base, self.owner_archive_view, name='owner_archive') ) - if self.location_archive_page: + if self.location_archive_page_id: urlpatterns += patterns('', url(r'^%s$' % self.location_permalink_base, self.location_archive_view, name='location_archive') ) diff --git a/philo/contrib/penfield/models.py b/philo/contrib/penfield/models.py index 9337589..53ae9c5 100644 --- a/philo/contrib/penfield/models.py +++ b/philo/contrib/penfield/models.py @@ -132,7 +132,7 @@ class BlogView(FeedView): def get_reverse_params(self, obj): if isinstance(obj, BlogEntry): - if obj.blog == self.blog: + if obj.blog_id == self.blog_id: kwargs = {'slug': obj.slug} if self.entry_permalink_style in 'DMY': kwargs.update({'year': str(obj.date.year).zfill(4)}) @@ -161,12 +161,12 @@ class BlogView(FeedView): urlpatterns = self.feed_patterns(r'^', 'get_all_entries', 'index_page', 'index') +\ self.feed_patterns(r'^%s/(?P[-\w]+[-+/\w]*)' % self.tag_permalink_base, 'get_entries_by_tag', 'tag_page', 'entries_by_tag') - if self.tag_archive_page: + if self.tag_archive_page_id: urlpatterns += patterns('', url((r'^%s$' % self.tag_permalink_base), self.tag_archive_view, name='tag_archive') ) - if self.entry_archive_page: + if self.entry_archive_page_id: if self.entry_permalink_style in 'DMY': urlpatterns += self.feed_patterns(r'^(?P\d{4})', 'get_entries_by_ymd', 'entry_archive_page', 'entries_by_year') if self.entry_permalink_style in 'DM': @@ -455,7 +455,7 @@ class NewsletterView(FeedView): def get_reverse_params(self, obj): if isinstance(obj, NewsletterArticle): - if obj.newsletter == self.newsletter: + if obj.newsletter_id == self.newsletter_id: kwargs = {'slug': obj.slug} if self.article_permalink_style in 'DMY': kwargs.update({'year': str(obj.date.year).zfill(4)}) @@ -465,7 +465,7 @@ class NewsletterView(FeedView): kwargs.update({'day': str(obj.date.day).zfill(2)}) return self.article_view, [], kwargs elif isinstance(obj, NewsletterIssue): - if obj.newsletter == self.newsletter: + if obj.newsletter_id == self.newsletter_id: return 'issue', [], {'numbering': obj.numbering} elif isinstance(obj, (date, datetime)): kwargs = { @@ -481,11 +481,11 @@ class NewsletterView(FeedView): urlpatterns = self.feed_patterns(r'^', 'get_all_articles', 'index_page', 'index') + patterns('', url(r'^%s/(?P.+)$' % self.issue_permalink_base, self.page_view('get_articles_by_issue', 'issue_page'), name='issue') ) - if self.issue_archive_page: + if self.issue_archive_page_id: urlpatterns += patterns('', url(r'^%s$' % self.issue_permalink_base, self.issue_archive_view, 'issue_archive') ) - if self.article_archive_page: + if self.article_archive_page_id: urlpatterns += self.feed_patterns(r'^%s' % self.article_permalink_base, 'get_all_articles', 'article_archive_page', 'articles') if self.article_permalink_style in 'DMY': urlpatterns += self.feed_patterns(r'^%s/(?P\d{4})' % self.article_permalink_base, 'get_articles_by_ymd', 'article_archive_page', 'articles_by_year') diff --git a/philo/contrib/waldo/models.py b/philo/contrib/waldo/models.py index 411cf8e..93b5add 100644 --- a/philo/contrib/waldo/models.py +++ b/philo/contrib/waldo/models.py @@ -164,13 +164,13 @@ class PasswordMultiView(LoginMultiView): def urlpatterns(self): urlpatterns = super(PasswordMultiView, self).urlpatterns - if self.password_reset_page and self.password_reset_confirmation_email and self.password_set_page: + if self.password_reset_page_id and self.password_reset_confirmation_email_id and self.password_set_page_id: urlpatterns += patterns('', url(r'^password/reset$', csrf_protect(self.password_reset), name='password_reset'), url(r'^password/reset/(?P\w+)/(?P[^/]+)$', self.password_reset_confirm, name='password_reset_confirm'), ) - if self.password_change_page: + if self.password_change_page_id: urlpatterns += patterns('', url(r'^password/change$', csrf_protect(self.login_required(self.password_change)), name='password_change'), ) @@ -329,7 +329,7 @@ class RegistrationMultiView(PasswordMultiView): @property def urlpatterns(self): urlpatterns = super(RegistrationMultiView, self).urlpatterns - if self.register_page and self.register_confirmation_email: + if self.register_page_id and self.register_confirmation_email_id: urlpatterns += patterns('', url(r'^register$', csrf_protect(self.register), name='register'), url(r'^register/(?P\w+)/(?P[^/]+)$', self.register_confirm, name='register_confirm') @@ -421,11 +421,11 @@ class AccountMultiView(RegistrationMultiView): @property def urlpatterns(self): urlpatterns = super(AccountMultiView, self).urlpatterns - if self.manage_account_page: + if self.manage_account_page_id: urlpatterns += patterns('', url(r'^account$', self.login_required(self.account_view), name='account'), ) - if self.email_change_confirmation_email: + if self.email_change_confirmation_email_id: urlpatterns += patterns('', url(r'^account/email/(?P\w+)/(?P[\w.]+[+][\w.]+)/(?P[^/]+)$', self.email_change_confirm, name='email_change_confirm') ) -- 2.20.1