diff --git a/rowers/emails.py b/rowers/emails.py index d209ee04..68c3dbfb 100644 --- a/rowers/emails.py +++ b/rowers/emails.py @@ -112,24 +112,27 @@ def send_template_email(from_email, to_email, subject, else: emailbounced = False - for recipient in to_email: - try: - soup = BeautifulSoup(html_content) + createmessage = kwargs.get('createmessage', True) - s2 = soup.body - - usr = User.objects.get(email=recipient) - umsg = UserMessage( - receiver = usr.rower, - datetime = timezone.now(), - text = '{text}'.format(text=s2), - subject=subject, - ) - umsg.save() - except User.DoesNotExist: - pass - except Exception as e: - pass + if createmessage: + for recipient in to_email: + try: + soup = BeautifulSoup(html_content) + + s2 = soup.body + + usr = User.objects.get(email=recipient) + umsg = UserMessage( + receiver = usr.rower, + datetime = timezone.now(), + text = '{text}'.format(text=s2), + subject=subject, + ) + umsg.save() + except User.DoesNotExist: + pass + except Exception as e: + pass if not emailbounced: res = msg.send() @@ -152,7 +155,7 @@ def send_confirm(user, name, link, options): # pragma: no cover _ = send_template_email('Rowsandall ', [fullemail], subject, 'confirmemail.html', - d + d, createmessage=False ) return 1 diff --git a/rowers/models.py b/rowers/models.py index 23503c71..28fce46e 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -1623,11 +1623,13 @@ timezones = ( class GeoCourse(models.Model): manager = models.ForeignKey(Rower, null=True, on_delete=models.SET_NULL) + followers = models.ManyToManyField(Rower, related_name='followed_courses') distance = models.IntegerField(default=0) name = models.CharField(max_length=150, blank=True) country = models.CharField(max_length=150, blank=True) notes = models.CharField(blank=True, max_length=200, verbose_name='Course Notes') + updated = models.DateTimeField(default=timezone.now, blank=True) def __str__(self): name = self.name @@ -1644,6 +1646,11 @@ class GeoCourse(models.Model): d=d, ) + def save(self, *args, **kwargs): + self.update = timezone.now() + super(GeoCourse, self).save(*args, **kwargs) + self.followers.add(self.manager) + @property def coord(self): return course_coord_center(self) diff --git a/rowers/templates/course_view.html b/rowers/templates/course_view.html index 37cb41d9..f1741712 100644 --- a/rowers/templates/course_view.html +++ b/rowers/templates/course_view.html @@ -34,6 +34,21 @@ Manager{{ course.manager }} +

+ {% if course in rower.followed_courses.all %} + You have liked this course. If you use CrewNerd, you can synchronize this course to your phone in the app. + {% else %} + By clicking on the link below, you can add the course to your "liked" list, which can be synchronized with the + CrewNerd app (from your phone). + {% endif %} +

+

+ {% if course in rower.followed_courses.all %} + Remove this course from your list of liked courses + {% else %} + Like this course + {% endif %} +

  • diff --git a/rowers/templates/list_courses.html b/rowers/templates/list_courses.html index a70edd17..dd60279f 100644 --- a/rowers/templates/list_courses.html +++ b/rowers/templates/list_courses.html @@ -3,11 +3,9 @@ {% load rowerfilters %} {% block title %}Rowsandall Courses List{% endblock %} - {% block scripts %} {% endblock %} - {% block main %}