def get_context_data(self, **kwargs): ctx = super(BaseProfileView, self).get_context_data(**kwargs) user_id = int(self.kwargs.get('id')) ctx.update(entity_base_view(self, Profile, {'user': user_id})) self.tabs = [ ('view', u'Инфо', reverse('profile', args=[user_id]), 'profiles/view.html'), ('tasks', u'Задачи: %i' % self.info['tasks']['admin']['count'], reverse('profile_tasks', args=[user_id]), 'tasks/list.html'), ('projects', u'Проекты: %i' % self.info['projects']['admin']['count'], reverse('profile_projects', args=[user_id]), 'projects/list.html'), ('ideas', u'Идеи: %i' % self.info['ideas']['admin']['count'], reverse('profile_ideas', args=[user_id]), 'ideas/list.html'), ] ctx.update(entity_tabs_view(self)) self.own_profile = (self.entity==self.request.profile) # TODO: UX_HACK if len(ctx['info']['locations']['entities']) > 0: location = ctx['info']['locations']['entities'][0]['instance'] else: location = None ctx.update({ 'title': unicode(self.entity), 'profile': self.entity, 'is_admin': self.own_profile, 'location': location, }) ctx.update(self.update_context()) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseProjectView, self).get_context_data(**kwargs) id = int(self.kwargs.get('id')) ctx.update(entity_base_view(self, Project, {'id': id})) self.tabs = [ ('view', u'Описание', reverse('project', args=[id]), 'projects/view.html'), ('wall', u'Комментарии: %i' % ctx['info']['comments']['count'], reverse('project_wall', args=[id]), 'projects/wall.html'), ('participants', u'Участники: %i' % self.info['providers'], reverse('project_participants', args=[id]), 'projects/participants.html'), ] ctx.update(entity_tabs_view(self)) # TODO: select_related it needed (?) location = ctx['info']['locations']['entities'][0]['instance'] # TODO: looks hacky ctx.update(breadcrumbs_context(location)) ctx.update({ 'title': u'Проект: '+self.entity.title, 'project': self.entity, 'admin': ctx['info']['participants']['admin']['entities'][0], # TODO: fix it }) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseLocationView, self).get_context_data(**kwargs) loc_id = int(kwargs["loc_id"]) # TODO: do we need select_related? (can we use location from cache?) try: location = Location.objects.select_related("region", "district").get(id=loc_id) except: # Location.DoesNotExist: # TODO: hack to overcome strange bug raise Http404(u"Район не найден") self.location = location self.info = location.info(related=True) # TODO: take it from cache (should be in location info) tasks_count = location.get_entities("tasks")(limit=0)["count"] projects_count = location.get_entities("projects")(limit=0)["count"] self.tabs = [ # ('map', u'Карта', reverse('location_map', args=[location.id]), '', 'locations/map.html'), ("tasks", u"Задачи: %i" % tasks_count, reverse("location_tasks", args=[location.id]), "tasks/list.html"), ( "projects", u"Проекты: %i" % projects_count, reverse("location_projects", args=[location.id]), "projects/list.html", ), ( "wall", u"Комментарии: %i" % self.info["comments"]["count"], reverse("location_wall", args=[location.id]), "locations/wall.html", ), ( "participants", u"Участники: %i" % self.info["participants"]["count"], reverse("location_participants", args=[location.id]), "locations/participants.html", ), ] ctx.update(entity_tabs_view(self)) ctx.update(breadcrumbs_context(location)) ctx.update( { "title": location.name, "loc_id": kwargs["loc_id"], # TODO: what is it for? "info": self.info, "is_participant": self.request.user.is_authenticated() and location.id in self.request.profile_info["locations"]["ids"], "is_lowest_level": location.is_lowest_level(), "is_location_page": True, } ) ctx.update(self.update_context()) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseReferendumView, self).get_context_data(**kwargs) self.tabs = [ ('questions', u'Вопросы: %i' % Question.objects.count(), reverse('referendum'), 'referendum/questions.html'), ('referendum_groups', u'Инициативные группы: %i' % InitiativeGroup.objects.count(), reverse('referendum_groups'), 'referendum/groups.html'), ('referendum_about', u'О референдуме', reverse('referendum_about'), 'referendum/about.html'), ] ctx.update(entity_tabs_view(self)) ctx.update({ 'title': u'Референдум', 'is_referendum_page': True, }) ctx.update(self.update_context()) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseQuestionView, self).get_context_data(**kwargs) id = int(self.kwargs.get('id')) ctx.update(entity_base_view(self, Question, {'id': id})) self.tabs = [ ('wall', u'Обсуждение: %i' % ctx['info']['comments']['count'], reverse('question', args=[id]), 'referendum/question_wall.html'), ('supporters', u'Поддержали: %i' % self.info['participants']['follower']['count'], reverse('question_supporters', args=[id]), 'referendum/question_supporters.html'), ] ctx.update(entity_tabs_view(self)) ctx.update({ 'title': u'Вопрос: '+self.entity.title, 'question': self.entity, 'is_referendum_page': True, }) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseInitiativeGroupView, self).get_context_data(**kwargs) id = int(self.kwargs.get('id')) ctx.update(entity_base_view(self, InitiativeGroup, {'id': id})) self.tabs = [ ('wall', u'Обсуждение: %i' % ctx['info']['comments']['count'], reverse('initiative_group', args=[id]), 'referendum/group_wall.html'), ('participants', u'Участники: %i' % self.info['participants']['follower']['count'], reverse('initiative_group_participants', args=[id]), 'referendum/group_participants.html'), ] ctx.update(entity_tabs_view(self)) ctx.update({ 'title': u'Инициативная группа: '+self.entity.location.name, 'group': self.entity, 'is_referendum_page': True, }) return ctx
def get_context_data(self, **kwargs): ctx = super(BaseProfileView, self).get_context_data(**kwargs) if self.tab == 'view': user_id = int(self.kwargs.get('id')) else: user_id = self.request.profile.user_id ctx.update(entity_base_view(self, Profile, {'user': user_id})) self.own_profile = (self.entity==self.request.profile) if self.own_profile: self.tabs = [ ('view', u'Инфо', reverse('profile', args=[user_id]), 'profiles/view.html'), ('edit', u'Редактировать', reverse('edit_profile'), 'profiles/edit.html'), ] else: self.tabs = [] ctx.update(entity_tabs_view(self)) if len(ctx['info']['locations']['entities']) > 0: location = ctx['info']['locations']['entities'][0]['instance'] else: location = None ctx.update({ 'title': unicode(self.entity), 'profile': self.entity, 'roles': self.entity.roles_set.select_related('location').order_by('type'), 'is_admin': self.own_profile, 'location': location, 'message_form': MessageForm(), }) ctx.update(self.update_context()) return ctx