Esempio n. 1
0
    def test_descriptions_are_added(self):
        self.ind.description = {'fi': 'testi', 'en': 'test'}
        self.ind.descriptionURL = {'sv': 'testurl'}

        self.ind.update()
        laji_ind = individual.get(self.ind.id)

        self.assertEquals('testi', laji_ind.description.get('fi'))
        self.assertEquals('test', laji_ind.description.get('en'))
        self.assertEquals('testurl', laji_ind.descriptionURL.get('sv'))
def _update_individual(request):
    if not _post_is_valid(request):
        return _return_with_context(request)

    individuale = individual.get(request.POST.get('id'))
    individuale.taxon = request.POST.get('taxon')
    individuale.ringID = request.POST.get('ring_id')
    individuale.nickname = request.POST.get('nickname')
    descriptionFields = _getDescriptionFields(request)
    individuale.description = descriptionFields[0]
    individuale.descriptionURL = descriptionFields[1]
    individuale.update()
    messages.add_message(request, messages.INFO, _('Tiedot tallennettu onnistuneesti!'))
Esempio n. 3
0
def getPublicGatheringsForIndividual(request):
    """
    REST-controller for getting bird-specific gatherings.
    """

    ids = request.GET.get('individualId').split(",")
    data = {}
    for id in ids:
        indiv = individual.get(id)
        gatherings = _get_gatherings_data(id, public_only=True, extras_onlymapdata=True)
        gatherings.append(indiv.nickname)
        data[id] = gatherings
    return Response(data)
Esempio n. 4
0
def _get_gatherings_data(individual_id, public_only=True, extras_originatingDevice=False, extras_onlymapdata=False):
    indiv = individual.get(individual_id)
    gatherings_obj = indiv.get_public_gatherings() if public_only else indiv.get_all_gatherings(extras_originatingDevice=extras_originatingDevice)
    gatherings_json = []

    for go in gatherings_obj:
        gj = go.to_lajistore_json()

        _move_altitude(gj)

        if public_only:
            _remove_publicity(gj)

        if extras_onlymapdata:
            gj['x'] = gj['wgs84Geometry']['coordinates'][1]
            gj['y'] = gj['wgs84Geometry']['coordinates'][0]
            del gj['wgs84Geometry']

            gj['d'] = gj['dateBegin']
            del gj['dateBegin']

            gj['t'] = gj['temperature']
            del gj['temperature']

            if 'altitude' in gj:
                gj['a'] = gj['altitude']
                del gj['altitude']

            del gj['higherGeography']
            del gj['country']

        if extras_originatingDevice:
            if not 'extras' in gj:
                gj['extras'] = {}
            gj['extras']['originatingDevice'] = go.extras['originatingDevice']

        gatherings_json.append(gj)

    return gatherings_json
def _delete_individual(request):
    individuale = individual.get(request.POST.get('id'))
    individuale.deleted = True
    individuale.update()
    messages.add_message(request, messages.INFO, _('Lintu poistettu onnistuneesti!'))
Esempio n. 6
0
 def test_get(self):
     self.assertEquals(self.ind.id, individual.get(self.ind.id).id)
Esempio n. 7
0
def set_individual_gatherings(request):
    gatherings = json.loads(compressedBase64ToString(request.POST['points']))
    indiv_id = request.GET['individual_id']
    indiv = individual.get(indiv_id)
    indiv.set_gatherings(gatherings)
    return Response({'success': True})