Skip to content

Commit

Permalink
Release1.1.1 (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mainlyIt authored Nov 25, 2024
1 parent 1fdcee7 commit afa0aeb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
32 changes: 18 additions & 14 deletions src/components/ObservationDetailsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class="btn btn-sm btn-outline-danger" @click="cancelReservation">Reservatie annuleren</button>
</div>

<div v-if="canViewRestrictedFields && canEdit" class="mb-3" id="edit">
<div v-if="canViewRestrictedFields" class="mb-3" id="edit">
<button class="btn btn-sm btn-outline-success" @click="confirmUpdate">Wijzigingen opslaan</button>
</div>
<div v-if="successMessage" class="alert alert-success alert-dismissible fade show" role="alert">
Expand Down Expand Up @@ -59,8 +59,9 @@
:class="{ 'is-invalid': eradicationResultError }" :disabled="!canEdit">
<option :value="null">Geen</option>
<option v-for="(label, value) in eradicationResultEnum" :key="value"
:value="value">{{ label
}}</option>
:value="value">
{{ label }}
</option>
</select>
<div v-if="eradicationResultError" class="invalid-feedback">
{{ eradicationResultError }}
Expand Down Expand Up @@ -266,14 +267,15 @@
</div>
<div>
<div class="row mb-2">
<label class="col-4 col-form-label">Validatiestatus</label>
<div class="col-8" v-if="selectedObservation.wn_validation_status !== undefined">
<p :value="null">Geen</p>
<p v-for="(label, value) in validationStatusEnum" :key="value" :value="value">{{
label }}</p>
<label class="col-4 col-form-label">Validatie</label>
<div class="col-8">
<p>
{{ validationStatusEnum[selectedObservation.wn_validation_status] || "Geen"
}}
</p>
</div>
</div>
<div v-if="canViewRestrictedFields" class="row mb-2">
<div class="row mb-2">
<label class="col-4 col-form-label">Opmerking validator</label>
<div class="col-8">
<p class="form-control-plaintext">{{ selectedObservation.notes }}</p>
Expand Down Expand Up @@ -320,7 +322,8 @@
<div class="row mb-2">
<label class="col-4 col-form-label">Telefoon</label>
<div class="col-8">
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}</p>
<p class="form-control-plaintext">{{ selectedObservation.observer_phone_number }}
</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -528,7 +531,7 @@ export default {
}
});
const canViewRestrictedFields = computed(() => {
return vespaStore.isAdmin ||
return vespaStore.isAdmin ||
(isLoggedIn.value && vespaStore.userMunicipalities.includes(selectedObservation.value?.municipality_name));
});
Expand Down Expand Up @@ -650,7 +653,7 @@ export default {
const today = new Date();
editableObservation.value.eradication_date = today.toISOString().split('T')[0];
}
// Format eradication_date if provided, and check for valid eradication result
if (editableObservation.value.eradication_date) {
const date = new Date(editableObservation.value.eradication_date);
Expand Down Expand Up @@ -679,7 +682,7 @@ export default {
errorMessage.value = 'Er is een fout opgetreden bij het opslaan van de wijzigingen.';
}
console.error('Error updating observation:', error);
}finally {
} finally {
isUpdating.value = false;
}
};
Expand Down Expand Up @@ -769,7 +772,8 @@ export default {
editableObservation,
errorMessage,
eradicationResultError,
canViewRestrictedFields
canViewRestrictedFields,
validationStatusEnum
};
}
};
Expand Down
5 changes: 3 additions & 2 deletions src/stores/vespaStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ export const useVespaStore = defineStore('vespaStore', {
)?.name;
return (
state.isLoggedIn &&
state.userMunicipalities.includes(municipalityName) &&
!observation.reserved_by
state.userMunicipalities.includes(municipalityName)
);
},
canEditAdminFields: (state) => state.isAdmin,
Expand Down Expand Up @@ -457,6 +456,8 @@ export const useVespaStore = defineStore('vespaStore', {
return '#198754';
} else if (status === 'eradicated') {
return '#198754';
} else if (status === 'unsuccessful') {
return '#198754';
} else if (status === 'reserved') {
return '#ea792a';
}
Expand Down
1 change: 0 additions & 1 deletion vespadb/observations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ class ObservationAdmin(gis_admin.GISModelAdmin):
"source",
"wn_id",
"wn_validation_status",
"wn_admin_notes",
"observer_name",
"observer_phone_number",
"created_datetime",
Expand Down
6 changes: 3 additions & 3 deletions vespadb/observations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from vespadb.observations.cache import invalidate_geojson_cache, invalidate_observation_cache
from vespadb.observations.filters import ObservationFilter
from vespadb.observations.helpers import parse_and_convert_to_utc
from vespadb.observations.models import Municipality, Observation, Province
from vespadb.observations.models import Municipality, Observation, Province, EradicationResultEnum
from vespadb.observations.serializers import (
MunicipalitySerializer,
ObservationSerializer,
Expand Down Expand Up @@ -393,7 +393,7 @@ def geojson(self, request: Request) -> HttpResponse:
"properties": {
"id": obs.id,
"status": "eradicated"
if obs.eradication_result == "successful"
if obs.eradication_result is not None
else "reserved"
if obs.reserved_by
else "default",
Expand Down Expand Up @@ -744,7 +744,7 @@ def serialize_observation(self, obj: Observation, headers: list[str], allowed_fi
elif field == "anb_domain":
data.append(str(obj.anb))
elif field == "eradication_result":
data.append(obj.eradication_result.value if obj.eradication_result else "")
data.append(obj.eradication_result if obj.eradication_result else "")
elif field == "nest_status":
logger.info("Getting status for observation %s", obj.eradication_result)
# This is handled as requested with eradication result
Expand Down
9 changes: 6 additions & 3 deletions vespadb/users/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
from vespadb.users.models import UserType, VespaUser


def get_system_user(user_type: Literal[UserType.SYNC, UserType.IMPORT]) -> VespaUser:
"""Get System Users based on usertype."""
def get_system_user(user_type: Literal[UserType.SYNC]) -> VespaUser:
"""Get the system user specifically for SYNC."""
if user_type != UserType.SYNC:
raise ValueError("This function only supports UserType.SYNC.")

system_user, _ = VespaUser.objects.get_or_create(
username=user_type.value, first_name="vespadb", defaults={"user_type": user_type.value}
username="sync", defaults={"user_type": UserType.SYNC.value}
)
return cast(VespaUser, system_user) # make mypy happy

0 comments on commit afa0aeb

Please sign in to comment.