views.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:django-danceschool 作者: django-danceschool 项目源码 文件源码
def get(self,request,*args,**kwargs):
        # These are passed via the URL
        year = self.kwargs.get('year')
        month = self.kwargs.get('month')
        slug = self.kwargs.get('slug','')

        try:
            month_number = list(month_name).index(month or 0)
        except ValueError:
            raise Http404(_('Invalid month.'))

        seriesset = get_list_or_404(Series,~Q(status=Event.RegStatus.hidden),~Q(status=Event.RegStatus.linkOnly),year=year or None,month=month_number or None,classDescription__slug=slug)

        # This will pass through to the context data by default
        kwargs.update({'seriesset': seriesset})

        # For each Series in the set, add a button to the toolbar to edit the Series details
        if hasattr(request,'user') and request.user.has_perm('core.change_series'):
            for this_series in seriesset:
                this_title = _('Edit Class Details')
                if len(seriesset) > 1:
                    this_title += ' (#%s)' % this_series.id
                request.toolbar.add_button(this_title, reverse('admin:core_series_change', args=([this_series.id,])), side=RIGHT)

        return super(IndividualClassView,self).get(request,*args,**kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号