From c81a9bc23cb260cc3da5fe1a85a90ddacf7c9511 Mon Sep 17 00:00:00 2001 From: xiez Date: Thu, 13 Sep 2012 17:45:15 +0800 Subject: [PATCH] Some updates --- views.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/views.py b/views.py index 3f759d41cc..39f82fa56c 100644 --- a/views.py +++ b/views.py @@ -193,8 +193,9 @@ class RepoMixin(object): return get_ccnetapplet_root() def get_current_commit(self): - # Implemented in subclasses. - pass + # Get newest commit by default, subclasses can override this method. + current_commit = get_commits(self.repo.id, 0, 1)[0] + return current_commit def get_success_url(self): return reverse('repo', args=[self.repo_id]) @@ -231,6 +232,9 @@ class RepoMixin(object): class RepoView(CtxSwitchRequiredMixin, RepoMixin, TemplateResponseMixin, BaseFormView): + """ + View to show repo page and handle post request to decrypt repo. + """ form_class = RepoPassowrdForm template_name = 'repo.html' @@ -256,10 +260,6 @@ class RepoView(CtxSwitchRequiredMixin, RepoMixin, TemplateResponseMixin, is_group_user(x.id, self.user.username)] return groups - def get_current_commit(self): - current_commit = get_commits(self.repo.id, 0, 1)[0] - return current_commit - def get_context_data(self, **kwargs): kwargs['repo'] = self.repo kwargs['can_access'] = self.can_access @@ -276,6 +276,9 @@ class RepoView(CtxSwitchRequiredMixin, RepoMixin, TemplateResponseMixin, return kwargs class RepoHistoryView(CtxSwitchRequiredMixin, RepoMixin, TemplateView): + """ + View to show repo page in history. + """ template_name = 'repo_history_view.html' def get_current_commit(self):