Пример #1
0
    def get_context_data(self, **kwargs):
        context = super(SimilarityExtrationView,
                        self).get_context_data(**kwargs)
        populate_context(self, context)
        database = context['current_database']

        if database is not None:
            if isinstance(database, TemporaryDatabase):
                data_matrices = DataMatrix.objects.filter(tmpdb=database)
            else:
                data_matrices = DataMatrix.objects.filter(database=database)

            completed_dms = data_matrices.filter(
                Q(task=None) | Q(task__stage__gte=TaskProgressStage.COMPLETED))
            all_ords = Ordination.objects.filter(dm__in=completed_dms)

            completed_ords = all_ords.filter(
                Q(task=None) | Q(task__stage__gte=TaskProgressStage.COMPLETED))

            context['completed_dms'] = completed_dms
            context['completed_ords'] = completed_ords

        context['all_incomplete_sims2tasks'] = get_incomplete_tasks(
            SimilarityIndex)

        return context
Пример #2
0
        def get_context_data(self, **kwargs):
            context = super(View, self).get_context_data(**kwargs)
            populate_context(self, context)

            extra_context_func = extra_context.get(self.__class__.page_name,
                                                   None)
            if extra_context_func:
                extra_context_func(self.request, context)

            return context
Пример #3
0
    def get_context_data(self, **kwargs):
        referrer_pathname = get_referrer_pathname(self.request)
        context = super(SongPartitionView, self).get_context_data(**kwargs)

        # Note: in FormView, url params exist in self.kwargs, not **kwargs.
        track_id = self.kwargs.get('track_id', None)
        if AudioTrack.objects.filter(id=track_id).exists():
            context['valid'] = True
        context['track_id'] = track_id
        context['referrer_pathname'] = referrer_pathname
        populate_context(self, context)

        return context
Пример #4
0
    def get_context_data(self, **kwargs):
        context = super(FeatureExtrationView, self).get_context_data(**kwargs)
        populate_context(self, context)
        database = context['current_database']

        if database is not None:
            if isinstance(database, TemporaryDatabase):
                data_matrices = DataMatrix.objects.filter(tmpdb=database)
            else:
                data_matrices = DataMatrix.objects.filter(database=database)

            completed_dms = data_matrices.filter(
                Q(task=None) | Q(task__stage__gte=TaskProgressStage.COMPLETED))
            incomplete_dms = data_matrices.filter(
                task__stage__lt=TaskProgressStage.COMPLETED)

            context['completed_dms'] = completed_dms
            context['incomplete_dms'] = incomplete_dms
        context['all_incomplete_dms2tasks'] = get_incomplete_tasks(DataMatrix)

        return context
Пример #5
0
    def get_context_data(self, **kwargs):
        context = super(SegmentationView, self).get_context_data(**kwargs)
        populate_context(self, context)
        user = self.request.user

        file_id = get_or_error(kwargs, 'file_id')
        audio_file = get_or_error(AudioFile, dict(id=file_id))
        track = audio_file.track
        individual = audio_file.individual
        quality = audio_file.quality
        date = track.date if track else None
        species = individual.species if individual else None

        context['file_id'] = file_id
        context['length'] = audio_file.length
        context['fs'] = audio_file.fs
        context['database'] = audio_file.database.id

        context['song_info'] = {
            'Length': '{:5.2f} secs'.format(audio_file.length / audio_file.fs),
            'Name': audio_file.name,
            'Species': str(species) if species else 'Unknown',
            'Date':
            date.strftime(settings.DATE_INPUT_FORMAT) if date else 'Unknown',
            'Quality': quality if quality else 'Unknown',
            'Track': track.name if track else 'Unknown',
            'Individual': individual.name if individual else 'Unknown',
            'Sex': individual.gender if individual else 'Unknown'
        }

        song_extra_attr_values_list = ExtraAttrValue.objects\
            .filter(user=user, attr__klass=AudioFile.__name__, owner_id=audio_file.id)\
            .values_list('attr__name', 'value')

        for attr, value in song_extra_attr_values_list:
            context['song_info']['Song\'s {}'.format(attr)] = value

        return context