for subscribe users always extract identifier from the user model
This commit is contained in:
parent
b63f7a8eff
commit
5df43b7cea
|
@ -45,6 +45,6 @@ class SubscriptionForm(forms.Form):
|
|||
for category, transport in wanted_subscriptions:
|
||||
models.Subscription.objects.get_or_create(
|
||||
user=self.user,
|
||||
identifier=self.user.mobile,
|
||||
identifier='',
|
||||
category=category,
|
||||
transport=transport)
|
||||
|
|
|
@ -80,7 +80,7 @@ class Subscription(TimeStampedModel):
|
|||
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('user'),
|
||||
blank=True, null=True)
|
||||
category = models.ForeignKey('Category', verbose_name=_('category'))
|
||||
identifier = models.CharField(_('identifier'), max_length=128, blank=False,
|
||||
identifier = models.CharField(_('identifier'), max_length=128, blank=True,
|
||||
help_text=_('ex.: email, mobile phone number, jabber id'))
|
||||
transport = models.CharField(_('transport'),
|
||||
max_length=32, choices=transports.get_transport_choices(),
|
||||
|
|
|
@ -181,7 +181,13 @@ class EmailTransport(object):
|
|||
|
||||
def get_emails(self, category):
|
||||
qs = self.get_subscriptions(category)
|
||||
return qs.values_list('identifier', flat=True).distinct()
|
||||
for subscription in qs:
|
||||
email = ''
|
||||
if subscription.identifier:
|
||||
email = subscription.identifier
|
||||
elif subscription.user:
|
||||
email = subscription.user.email
|
||||
yield email
|
||||
|
||||
def send(self, announce):
|
||||
category = announce.category
|
||||
|
|
Reference in New Issue