I have an abstract class called Notification. I have 2 concrete implementations which are NearNotification and FarNotification.
Each has a different entity associated with them. One is a Department and one is a Group.
I want to send an email to an email associated with either a Department for a NearNotification or a Group for FarNotifications.
Right now my abstract Notification class looks like:
class Notification(models.Model):
name = models.CharField(max_length=256)
class Meta:
abstract = True
def send(self):
group_email = self.group.email
department_email = self.department.email
Depending on which class is created, Department or Group the department or Group field is populated.
How can I conditionally sort on this subclass to determine which email to use?
Something like
def send(self):
if concrete class = FarNotification:
group_email = self.group.email
elif if concrete class = NearNotification:
department_email = self.department.email