views.py 文件源码

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

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

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

        eventset = get_list_or_404(PublicEvent,~Q(status=Event.RegStatus.hidden),~Q(status=Event.RegStatus.linkOnly),year=year,month=month_number,slug=slug)

        # If an alternative link is given by one or more of these events, then redirect to that.
        overrideLinks = [x.link for x in eventset if x.link]
        if overrideLinks:
            return HttpResponseRedirect(overrideLinks[0])

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

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

        return super(IndividualEventView,self).get(request,*args,**kwargs)


#####################################
# View for Repeating Events from admin
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号