Ejemplo n.º 1
0
 def get_context_data(self, **kwargs):
     try:
         context = super(PersonneDetail, self).get_context_data(**kwargs)
         # Obtain values of the record authority
         context['personne'] = tools.request_api(
             '/api/authority/' + context['id'])
         context['contribs'] = tools.request_api(
             '/api/authority/' + context['id'] + '/contribs')
         context['form'] = PersonneForm
     except Http404:
         raise Http404(_('Cette personne n’existe pas.'))
     except Exception as err:
         context['personne'] = {}
         context['contribs'] = {}
         context['error'] = err
     return context
Ejemplo n.º 2
0
 def get_context_data(self, **kwargs):
     try:
         context = super(LanguageView, self).get_context_data(**kwargs)
         context['languages'] = tools.request_api('/api/language')
     except Exception as err:
         context['languages'] = []
         context['error'] = err
     return context
Ejemplo n.º 3
0
 def get_context_data(self, **kwargs):
     try:
         context = super(InstrumentView, self).get_context_data(**kwargs)
         context['instruments'] = tools.request_api('/api/instrument')
     except Exception as err:
         context['instruments'] = []
         context['error'] = err
     return context
Ejemplo n.º 4
0
 def get_context_data(self, **kwargs):
     try:
         context = super(LocationView, self).get_context_data(**kwargs)
         context['locations'] = tools.request_api('/api/locationgis')
     except Exception as err:
         context['locations'] = []
         context['error'] = err
     return context
Ejemplo n.º 5
0
    def get_context_data(self, **kwargs):
        try:
            context = super(LegalRightsView, self).get_context_data(**kwargs)
            context['legal_rights'] = tools.request_api('/api/legalrights')
        except Exception as err:
            context['legal_rights'] = []
            context['error'] = err

        return context
Ejemplo n.º 6
0
    def get_context_data(self, **kwargs):
        try:
            context = super(PublisherView, self).get_context_data(**kwargs)
            context['publishers'] = tools.request_api('/api/publisher')
        except Exception as err:
            context['publishers'] = []
            context['error'] = err

        return context
Ejemplo n.º 7
0
    def get_context_data(self, **kwargs):
        try:
            context = super(MusicalGroupView, self).get_context_data(**kwargs)
            context['musical_groups'] = tools.request_api('/api/musical_group')
        except Exception as err:
            context['musical_group'] = []
            context['error'] = err

        return context
Ejemplo n.º 8
0
    def get_context_data(self, **kwargs):
        try:
            context = super(EmitVoxView, self).get_context_data(**kwargs)
            context['emit_voxs'] = tools.request_api('/api/emit_vox')
        except Exception as err:
            context['emit_voxs'] = []
            context['error'] = err

        return context
Ejemplo n.º 9
0
    def get_context_data(self, **kwargs):
        try:
            context = super(DomainVocalView, self).get_context_data(**kwargs)
            context['domain_vocals'] = tools.request_api('/api/domain_vocal')
        except Exception as err:
            context['domain_vocals'] = []
            context['error'] = err

        return context
Ejemplo n.º 10
0
    def get_context_data(self, **kwargs):
        try:
            context = super(ThematicView, self).get_context_data(**kwargs)
            context['thematics'] = tools.request_api('/api/thematic')
        except Exception as err:
            context['thematics'] = []
            context['error'] = err

        return context
Ejemplo n.º 11
0
    def get_context_data(self, **kwargs):
        try:
            context = super(MediaTypeView, self).get_context_data(**kwargs)
            context['mediatypes'] = tools.request_api('/api/mediatype')
        except Exception as err:
            context['mediatypes'] = []
            context['error'] = err

        return context
Ejemplo n.º 12
0
    def get_context_data(self, **kwargs):
        try:
            context = super(UsefulnessView, self).get_context_data(**kwargs)
            context['usefulnesss'] = tools.request_api('/api/usefulness')
        except Exception as err:
            context['usefulnesss'] = []
            context['error'] = err

        return context
Ejemplo n.º 13
0
 def get_context_data(self, **kwargs):
     try:
         context = super(LocationDetail, self).get_context_data(**kwargs)
         # Obtain values of the record location
         context['location'] = tools.request_api(
             '/api/locationgis/' + context['id'])
         # Obtain values of related collections
         context['collections'] = tools.request_api(
             '/api/locationgis/' + context['id'] + '/collections')
         # Obtain values of related items
         context['items'] = tools.request_api(
             '/api/locationgis/' + context['id'] + '/items')
         context['form'] = LocationForm
     except Exception as err:
         context['location'] = {}
         context['collections'] = []
         context['items'] = []
         context['error'] = err
     return context
Ejemplo n.º 14
0
    def get_context_data(self, **kwargs):
        try:
            context = super(HornbostelsachsView,
                            self).get_context_data(**kwargs)
            context['hornbostelsachss'] = tools.request_api(
                '/api/hornbostelsachs')
        except Exception as err:
            context['hornbostelsachss'] = []
            context['error'] = err

        return context
Ejemplo n.º 15
0
    def get_context_data(self, **kwargs):
        try:
            context = super(MetadataAuthorView,
                            self).get_context_data(**kwargs)
            context['metadata_author'] = tools.request_api(
                '/api/metadata_author')
        except Exception as err:
            context['metadata_author'] = []
            context['error'] = err

        return context
Ejemplo n.º 16
0
    def get_context_data(self, **kwargs):
        try:
            context = super(CoiraultDetail, self).get_context_data(**kwargs)
            context['coirault'] = tools.request_api('/api/skos_concept/' +
                                                    context['id'])
            context['form'] = CoiraultForm()

        except Exception as err:
            context['coirault'] = {}
            context['error'] = err
            context['form'] = CoiraultForm()
        return context
    def get(self, request, *args, **kwargs):

        record_id = kwargs.get('id')

        # Obtain values of the record
        record = tools.request_api(self.api_url_prefix + str(record_id))
        form = self.form_class(initial=record)

        return render(request, self.template_name, {
            'form': form,
            'id': record_id,
            self.template_variable_name: record,
        })
Ejemplo n.º 18
0
    def get_context_data(self, **kwargs):
        try:
            context = super(MetadataAuthorDetail,
                            self).get_context_data(**kwargs)
            context['metadata_author'] = tools.request_api(
                '/api/metadata_author/' + context['id'])
            context['form'] = MetadataAuthorForm()

        except Exception as err:
            context['metadata_author'] = {}
            context['error'] = err
            context['form'] = MetadataAuthorForm()
        return context
    def get_context_data(self, **kwargs):
        try:
            context = super(FrancoralitePaginatedTemplateView,
                            self).get_context_data(**kwargs)

            try:
                page = int(self.request.GET.get('page', None)) or 1
                if page < 1:
                    page = 1
            except:
                page = 1
            offset = self.PAGE_SIZE * (page - 1)

            api_response = tools.request_api('%s%slimit=%s&offset=%s' % (
                self.api_url,
                '&' if '?' in self.api_url else '?',
                self.PAGE_SIZE,
                offset,
            ))

            results_count = api_response.get('count') or 0
            last_page = (results_count - 1) // self.PAGE_SIZE + 1

            context[self.context_results_name] = api_response.get(
                'results', ())
            context['pagination'] = {
                'count': results_count,
                'page_size': self.PAGE_SIZE,
                'current_page': page,
                'has_previous': page > 1,
                'has_next': page * self.PAGE_SIZE < results_count,
                'first_item': min(self.PAGE_SIZE * (page - 1) + 1,
                                  results_count),
                'last_item': min(self.PAGE_SIZE * page, results_count),
                'last_page': last_page,
                'pages': tuple(range(1, last_page + 1)),
            }

        except Exception as err:
            context[self.context_results_name] = []
            context['error'] = err

        return context
Ejemplo n.º 20
0
 def get_context_data(self, **kwargs):
     try:
         context = super(SearchView, self).get_context_data(**kwargs)
         query = self.request.GET['q']
         context['query'] = query
         context['results'] = tools.request_api(
             '/globalsearch/?q=' + query)
         context['topics'] = {
             "Authority": _(u"Personnes"),
             "Location": _(u"Lieux"),
             "Fond": _(u"Fonds"),
             "Mission": _(u"Mission"),
             "Collection": _(u"Enquête"),
             "Item": _(u"Item")
         }
     except Exception as err:
         context['results'] = []
         context['error'] = err
     return context
Ejemplo n.º 21
0
    def get(self, request, *args, **kwargs):
        if request.GET:
            url = '/advancedsearch/?' + urlencode(request.GET, doseq=True)
            api_response = request_api(url)
        else:
            api_response = {}

        context = self.get_context_data(**kwargs)
        context['show_results'] = bool(api_response)
        context['collections'] = api_response.get('results', {}).get('collections', ())
        context['items'] = api_response.get('results', {}).get('items', ())
        context['locations'] = api_response.get('results', {}).get('locations', ())

        context['parameters'] = api_response.get('parameters', {})
        context['parameters_instances_json'] = dict(
            (name, json.dumps(values))
            for name, values in api_response.get('parameters', {}).get('instances', {}).items()
        )

        return self.render_to_response(context)