Example #1
0
    def get_queryset(self):
        '''
        Returns list of changes to browse.
        '''
        project = None
        subproject = None
        translation = None
        language = None
        user = None

        # Filtering by translation/project
        if 'project' in self.request.GET:
            try:
                project, subproject, translation = get_project_translation(
                    self.request,
                    self.request.GET.get('project', None),
                    self.request.GET.get('subproject', None),
                    self.request.GET.get('lang', None),
                )
            except Http404:
                messages.error(self.request, _('Invalid search string!'))

        # Filtering by language
        if translation is None and 'lang' in self.request.GET:
            try:
                language = Language.objects.get(
                    code=self.request.GET['lang']
                )
            except Language.DoesNotExist:
                messages.error(self.request, _('Invalid search string!'))

        # Filtering by user
        if 'user' in self.request.GET:
            try:
                user = User.objects.get(
                    username=self.request.GET['user']
                )
            except User.DoesNotExist:
                messages.error(self.request, _('Invalid search string!'))

        result = Change.objects.all()

        if translation is not None:
            result = result.filter(translation=translation)
        elif subproject is not None:
            result = result.filter(translation__subproject=subproject)
        elif project is not None:
            result = result.filter(translation__subproject__project=project)

        if language is not None:
            result = result.filter(translation__language=language)

        if user is not None:
            result = result.filter(user=user)

        return result
Example #2
0
    def get_queryset(self):
        '''
        Returns list of changes to browse.
        '''
        project = None
        subproject = None
        translation = None
        language = None
        user = None

        # Filtering by translation/project
        if 'project' in self.request.GET:
            try:
                project, subproject, translation = get_project_translation(
                    self.request,
                    self.request.GET.get('project', None),
                    self.request.GET.get('subproject', None),
                    self.request.GET.get('lang', None),
                )
            except Http404:
                messages.error(self.request, _('Invalid search string!'))

        # Filtering by language
        if translation is None and 'lang' in self.request.GET:
            try:
                language = Language.objects.get(code=self.request.GET['lang'])
            except Language.DoesNotExist:
                messages.error(self.request, _('Invalid search string!'))

        # Filtering by user
        if 'user' in self.request.GET:
            try:
                user = User.objects.get(username=self.request.GET['user'])
            except User.DoesNotExist:
                messages.error(self.request, _('Invalid search string!'))

        result = Change.objects.all()

        if translation is not None:
            result = result.filter(translation=translation)
        elif subproject is not None:
            result = result.filter(translation__subproject=subproject)
        elif project is not None:
            result = result.filter(translation__subproject__project=project)

        if language is not None:
            result = result.filter(translation__language=language)

        if user is not None:
            result = result.filter(user=user)

        return result
Example #3
0
def yearly_activity(request, project=None, subproject=None, lang=None):
    '''
    Show yearly activity chart.
    '''

    # Process parameters
    project, subproject, translation = get_project_translation(
        request,
        project,
        subproject,
        lang
    )

    # Get actual stats
    activity = Change.objects.year_stats(
        project,
        subproject,
        translation
    )

    # Render chart
    return render_activity(activity)
Example #4
0
def yearly_activity(request, project=None, subproject=None, lang=None):
    '''
    Show yearly activity chart.
    '''

    # Process parameters
    project, subproject, translation = get_project_translation(
        request,
        project,
        subproject,
        lang
    )

    # Get actual stats
    activity = Change.objects.year_stats(
        project,
        subproject,
        translation
    )

    # Render chart
    return render_activity(activity)
Example #5
0
    def get_queryset(self):
        '''
        Returns list of changes to browse.
        '''
        # Filtering by translation/project
        if 'project' in self.request.GET:
            try:
                self.project, self.subproject, self.translation = \
                    get_project_translation(
                        self.request,
                        self.request.GET.get('project', None),
                        self.request.GET.get('subproject', None),
                        self.request.GET.get('lang', None),
                    )
            except Http404:
                messages.error(
                    self.request,
                    _('Failed to find matching project!')
                )

        # Filtering by language
        if self.translation is None and 'lang' in self.request.GET:
            try:
                self.language = Language.objects.get(
                    code=self.request.GET['lang']
                )
            except Language.DoesNotExist:
                messages.error(
                    self.request,
                    _('Failed to find matching language!')
                )

        # Filtering by user
        if 'user' in self.request.GET:
            try:
                self.user = User.objects.get(
                    username=self.request.GET['user']
                )
            except User.DoesNotExist:
                messages.error(
                    self.request,
                    _('Failed to find matching user!')
                )

        # Glossary entries
        self.glossary = 'glossary' in self.request.GET

        result = Change.objects.prefetch()

        if self.translation is not None:
            result = result.filter(
                translation=self.translation
            )
        elif self.subproject is not None:
            result = result.filter(
                translation__subproject=self.subproject
            )
        elif self.project is not None:
            result = result.filter(
                Q(translation__subproject__project=self.project) |
                Q(dictionary__project=self.project)
            )

        if self.language is not None:
            result = result.filter(
                Q(translation__language=self.language) |
                Q(dictionary__language=self.language)
            )

        if self.glossary:
            result = result.filter(
                dictionary__isnull=False
            )

        if self.user is not None:
            result = result.filter(
                user=self.user
            )

        return result
Example #6
0
def view_activity(request, project=None, subproject=None, lang=None):
    '''
    Show html with activity charts.
    '''

    # Process parameters
    project, subproject, translation = get_project_translation(
        request,
        project,
        subproject,
        lang
    )

    if translation is not None:
        kwargs = {
            'project': project.slug,
            'subproject': subproject.slug,
            'lang': translation.language.code,
        }
        monthly_url = reverse(
            'monthly_activity_translation',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_translation',
            kwargs=kwargs
        )
    elif subproject is not None:
        kwargs = {
            'project': project.slug,
            'subproject': subproject.slug,
        }
        monthly_url = reverse(
            'monthly_activity_subproject',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_subproject',
            kwargs=kwargs
        )
    elif project is not None:
        kwargs = {
            'project': project.slug,
        }
        monthly_url = reverse(
            'monthly_activity_project',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_project',
            kwargs=kwargs
        )
    else:
        monthly_url = reverse(
            'monthly_activity',
        )
        yearly_url = reverse(
            'yearly_activity',
        )

    return render_to_response('js/activity.html', RequestContext(request, {
        'yearly_url': yearly_url,
        'monthly_url': monthly_url,
    }))
Example #7
0
def view_activity(request, project=None, subproject=None, lang=None):
    '''
    Show html with activity charts.
    '''

    # Process parameters
    project, subproject, translation = get_project_translation(
        request,
        project,
        subproject,
        lang
    )

    if translation is not None:
        kwargs = {
            'project': project.slug,
            'subproject': subproject.slug,
            'lang': translation.language.code,
        }
        monthly_url = reverse(
            'monthly_activity_translation',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_translation',
            kwargs=kwargs
        )
    elif subproject is not None:
        kwargs = {
            'project': project.slug,
            'subproject': subproject.slug,
        }
        monthly_url = reverse(
            'monthly_activity_subproject',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_subproject',
            kwargs=kwargs
        )
    elif project is not None:
        kwargs = {
            'project': project.slug,
        }
        monthly_url = reverse(
            'monthly_activity_project',
            kwargs=kwargs
        )
        yearly_url = reverse(
            'yearly_activity_project',
            kwargs=kwargs
        )
    else:
        monthly_url = reverse(
            'monthly_activity',
        )
        yearly_url = reverse(
            'yearly_activity',
        )

    return render_to_response('js/activity.html', RequestContext(request, {
        'yearly_url': yearly_url,
        'monthly_url': monthly_url,
    }))