Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
    def get_context_data(self, **kwargs):
        ctx = super(IdeaView, self).get_context_data(**kwargs)

        id = int(self.kwargs.get('id'))
        ctx.update(entity_base_view(self, Idea, {'id': id}))

        location = self.entity.task.info()['locations']['entities'][0]['instance']
        ctx.update(breadcrumbs_context(location))

        projects = [pi.project for pi in self.entity.projects.select_related('project')]
        ctx.update({
            'title': u'Идея к задаче "%s"' % self.entity.task.title,
            'idea': self.entity,
            'admin': self.info['participants']['admin']['entities'][0],
            'projects': projects,
        })
        return ctx
Beispiel #4
0
    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
Beispiel #5
0
    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
Beispiel #6
0
    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