def get_notifications_by_date2(self, after_date_year,after_date_month,after_date_day): ''' params (token : String, after_date : list[year, month, day]) ''' from datetime import datetime after_date = datetime(after_date_year, after_date_month, after_date_day) notifications = Notification.objects.filter(time__gte=after_date) reformed_notifications = queryset_to_list_of_dicts(notifications) if reformed_notifications: return reformed_notifications else: return 'no notifications after this date'
def get_news_by_date(self, after_date): ''' params (token, after_date) ''' from datetime import date after_date = date(after_date[0], after_date[1], after_date[2]) news = News.objects.filter(date__gte=after_date) reformed_news = queryset_to_list_of_dicts(news) if reformed_news: return reformed_news else: return 'no notifications after this date'
def get_notifications_by_location(self, lon, lat, delta): ''' params (lon, lat, delta) ''' notifications = Notification.objects.filter(lon__gt=(lon - delta)) notifications = notifications.filter(lat__gt=(lat - delta)) notifications = notifications.filter(lon__lt=(lon + delta)) notifications = notifications.filter(lat__lt=(lat + delta)) reformed_notifications = queryset_to_list_of_dicts(notifications) if reformed_notifications: return reformed_notifications else: return 'no notifications in this area'