from django.template.loader import render_to_string
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
+from django.core.exceptions import ValidationError
+
from urllib import quote
from urlparse import urljoin
from smtplib import SMTPException
Raises SendInvitationError
"""
subject = _('Invitation to %s alpha2 testing' % SITENAME)
- url = '%s?code=%d' % (urljoin(BASEURL, reverse('astakos.im.views.signup')), invitation.code)
+ url = '%s?code=%d' % (urljoin(BASEURL, reverse('astakos.im.views.index')), invitation.code)
message = render_to_string('im/invitation.txt', {
'invitation': invitation,
'url': url,
"""
Activates the specific user and sends email.
- Raises SendGreetingError
+ Raises SendGreetingError, ValidationError
"""
user.is_active = True
user.save()
Raises SendInvitationError
"""
+ invitation.inviter = inviter
+ invitation.save()
send_invitation(invitation, email_template_name)
inviter.invitations = max(0, inviter.invitations - 1)
inviter.save()
def set_user_credibility(email, has_credits):
try:
- user = AstakosUser.objects.get(email=email)
+ user = AstakosUser.objects.get(email=email, is_active=True)
user.has_credits = has_credits
user.save()
except AstakosUser.DoesNotExist, e:
logger.exception(e)
+ except ValidationError, e:
+ logger.exception(e)
class SendMailError(Exception):
- def __init__(self, message):
- Exception.__init__(self)
+ pass
class SendAdminNotificationError(SendMailError):
def __init__(self):
self.message = _('Failed to send notification')
- SendMailError.__init__(self)
+ super(SendAdminNotificationError, self).__init__()
-class SendVerificationError(Exception):
+class SendVerificationError(SendMailError):
def __init__(self):
self.message = _('Failed to send verification')
- SendMailError.__init__(self)
+ super(SendVerificationError, self).__init__()
-class SendInvitationError(Exception):
+class SendInvitationError(SendMailError):
def __init__(self):
self.message = _('Failed to send invitation')
- SendMailError.__init__(self)
+ super(SendInvitationError, self).__init__()
-class SendGreetingError(Exception):
+class SendGreetingError(SendMailError):
def __init__(self):
self.message = _('Failed to send greeting')
- SendMailError.__init__(self)
+ super(SendGreetingError, self).__init__()
-class SendFeedbackError(Exception):
+class SendFeedbackError(SendMailError):
def __init__(self):
self.message = _('Failed to send feedback')
- SendMailError.__init__(self)
\ No newline at end of file
+ super(SendFeedbackError, self).__init__()
\ No newline at end of file