I'm passing date parameters from angualrjs controller to my restapi, now the date parameter is not specified so I need to filter by default with now() and earlier on parameter which I'm sending to restapi so if I'm understanding correctly filter should be in the get function on the view, probably, like I said probably because I'm in a dilemma on this one, and asking from someone to explain to me how can I do this. You can check my controller and view down bellow.
app = angular.module 'cms.sales'
app.controller 'FilterContactsListCtrl', ['$scope', '$http',
($scope, $http) ->
savedSuccessMessage = "Contact leads list was updated"
savedFailMessage = "Failed to update contact leads list"
$scope.selectDate = null
$scope.init = (nextSelectedDate)->
if nextSelectedDate
$scope.selectDate = nextSelectedDate
else
$scope.selectDate = ""
$scope.doAction = () ->
data = {
select_date: $scope.selectDate
}
$http.post("/api/sales/lead_contact/", data).then(
nextContactListUpdateSuccess, nextContactListUpdateFailed
)
nextContactListUpdateSuccess = ()->
ClientNotifications.showNotification("Success", "Contact Leads list page was updated", "success")
nextContactListUpdateFailed = () ->
ClientNotifications.showNotification("Alert", "Failed to update contact leads list page", "alert")
]
ModelViewSet:
class LeadContactViewSet(viewsets.ModelViewSet):
def get_queryset(self):
queryset = LeadContact.objects.none()
user = self.request.user
if user.has_perm('vinclucms_sales.can_view_full_lead_contact_list'):
queryset = LeadContact.objects.all()
elif user.has_perm('cms_sales.can_view_lead_contact'):
queryset = LeadContact.objects.filter(account_handler=user)
return queryset
# rest of the view below
.....