Merge branch 'feature/module_1' into development

This commit is contained in:
bobbyvish
2024-07-02 19:23:41 +05:30
2 changed files with 23 additions and 7 deletions

View File

@@ -521,7 +521,7 @@ class CustomerVenueFilterView(LoginRequiredMixin, generic.View):
pk = request.GET.get("pk", None)
if not pk:
return JsonResponseUtil.error(message="Non transfer user list field is required")
obj = self.model.objects.filter(principal=pk)
obj = self.model.objects.filter(principal=pk, active=True)
if not obj.exists():
return JsonResponseUtil.error(message="No venue found for the given user.")

View File

@@ -92,13 +92,13 @@
function handlePrincipalChange() {
$("#id_principal").change(function(){
var selectedPrincipalId = $(this).val();
// clear existing venue options
// Clear existing venue options
$("#id_venue").empty().append($("<option value='' selected=''>---------</option>"));
if (selectedPrincipalId){
if (selectedPrincipalId) {
$.ajax({
url: "{% url 'manage_events:venue_customer_filter'%}",
url: "{% url 'manage_events:venue_customer_filter' %}",
type: "GET",
data: { pk: selectedPrincipalId },
success: function(data) {
@@ -106,6 +106,12 @@
$.each(data.data, function(index, venue) {
$("#id_venue").append($("<option></option>").val(venue.id).text(venue.title));
});
// Preselect the venue if a value is already selected
var selectedVenueId = $("#id_venue").data('selected-venue');
if (selectedVenueId) {
$("#id_venue").val(selectedVenueId);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error("Error fetching venue data:", textStatus, errorThrown);
@@ -120,8 +126,18 @@
});
}
});
// Store the selected venue data
var selectedVenueId = "{{ form.venue.value }}";
$("#id_venue").data('selected-venue', selectedVenueId);
// Trigger change event if a principal value is already selected
var selectedPrincipalId = $("#id_principal").val();
if (selectedPrincipalId) {
$("#id_principal").trigger("change");
}
}
$(document).ready(function() {
// Set multiple attribute for event images
document.getElementById('id_event_images').setAttribute('multiple', '');