Esempio n. 1
0
 def notify(self):
     user_email_addresses_to_notify = []
     print("Got here: %s" % self)
     for group in self.groups.all():
         print("Group to notify: %s" % group)
         for user in group.users.all():
             print("User to notify: %s" % user)
             for notification_zone in NotificationZone.objects.filter(
                     user=user):
                 is_in_range = GeoRangeChecker.is_in_range_mi(
                     notification_zone.radius, notification_zone.latitude,
                     notification_zone.longitude, self.latitude,
                     self.longitude)
                 if is_in_range:
                     user_email_addresses_to_notify.append(user.email)
     messages = []
     print("Emails to notify: %s" % user_email_addresses_to_notify)
     for email_address in user_email_addresses_to_notify:
         message = ('Notification', 'Here is the message',
                    '*****@*****.**', [email_address])
         messages.append(message)
     send_mass_mail(messages, fail_silently=False)
Esempio n. 2
0
 def notify(self):
     user_email_addresses_to_notify = []
     print("Got here: %s" % self)
     for group in self.groups.all():
         print("Group to notify: %s" % group)
         for user in group.users.all():
             print("User to notify: %s" % user)
             for notification_zone in NotificationZone.objects.filter(user=user):
                 is_in_range = GeoRangeChecker.is_in_range_mi(
                     notification_zone.radius,
                     notification_zone.latitude,
                     notification_zone.longitude,
                     self.latitude,
                     self.longitude
                 )
                 if is_in_range:
                     user_email_addresses_to_notify.append(user.email)
     messages = []
     print("Emails to notify: %s" % user_email_addresses_to_notify)
     for email_address in user_email_addresses_to_notify:
         message = ('Notification', 'Here is the message', '*****@*****.**', [email_address])
         messages.append(message)
     send_mass_mail(messages, fail_silently=False)
Esempio n. 3
0
 def notify(self):
     users_to_notify = []
     for group in self.groups.all():
         for user in group.users.all():
             for notification_zone in NotificationZone.objects.filter(user=user):
                 is_in_range = GeoRangeChecker.is_in_range_mi(
                     notification_zone.radius,
                     notification_zone.latitude,
                     notification_zone.longitude,
                     self.latitude,
                     self.longitude
                 )
                 if is_in_range:
                     users_to_notify.append(user)
     messages = []
     for user in users_to_notify:
         body = "Hey! {0} wanted you to know about something happening on {1} at {2}".format(self.user.username, self.date, self.time)
         message = ('KnoWhere: %s' % self.title,
                    body,
                    '*****@*****.**',
                    ["%s" % user.email])
         messages.append(message)
     send_mass_mail(messages, fail_silently=False)
 def test_is_in_range_mi(self):
     destination_points_are_within_range = GeoRangeChecker.is_in_range_mi(
         self.RANGE_IN_KM, self.ORIGIN_LAT, self.ORIGIN_LON, self.DESTINATION_LAT, self.DESTINATION_LON)
     self.assertTrue(destination_points_are_within_range)
 def test_calculation_of_distance_in_mi(self):
     calculated_distance_between_points_in_mi = GeoRangeChecker.get_distance_in_mi(
         self.ORIGIN_LAT, self.ORIGIN_LON, self.DESTINATION_LAT, self.DESTINATION_LON)
     self.assertEquals(calculated_distance_between_points_in_mi, self.DISTANCE_BETWEEN_POINTS_IN_MI)
 def test_is_in_range_mi(self):
     destination_points_are_within_range = GeoRangeChecker.is_in_range_mi(
         self.RANGE_IN_KM, self.ORIGIN_LAT, self.ORIGIN_LON,
         self.DESTINATION_LAT, self.DESTINATION_LON)
     self.assertTrue(destination_points_are_within_range)
 def test_calculation_of_distance_in_mi(self):
     calculated_distance_between_points_in_mi = GeoRangeChecker.get_distance_in_mi(
         self.ORIGIN_LAT, self.ORIGIN_LON, self.DESTINATION_LAT,
         self.DESTINATION_LON)
     self.assertEquals(calculated_distance_between_points_in_mi,
                       self.DISTANCE_BETWEEN_POINTS_IN_MI)