Commit fc28d013 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

fix bugs

* welcome_email.txt template location
* in activateuser do not change user's state in case of send_email failure
* fix inviteuser
parent cbea03d1
......@@ -45,7 +45,7 @@ from astakos.im.models import Invitation
logger = logging.getLogger(__name__)
def activate(user, email_template_name='welcome_email.txt'):
def activate(user, email_template_name='im/welcome_email.txt'):
"""
Activates the specific user and sends email.
......@@ -56,7 +56,7 @@ def activate(user, email_template_name='welcome_email.txt'):
subject = _('Welcome to %s' % SITENAME)
message = render_to_string(email_template_name, {
'user': user,
'url': urljoin(BASEURL, reverse('astakos.im.views')),
'url': urljoin(BASEURL, reverse('astakos.im.views.index')),
'baseurl': BASEURL,
'site_name': SITENAME,
'support': DEFAULT_CONTACT_EMAIL})
......
......@@ -57,6 +57,11 @@ class Command(BaseCommand):
self.stderr.write(msg)
continue
activate(user)
try:
activate(user)
transaction.commit()
except Exception, e:
transaction.rollback()
raise e
self.stdout.write("Activated '%s'\n" % (user.email,))
self.stdout.write("Activated '%s'\n" % (user.email,))
\ No newline at end of file
......@@ -50,8 +50,8 @@ class Command(BaseCommand):
if len(args) != 3:
raise CommandError("Invalid number of arguments")
user = get_user(args[0])
if not user:
inviter = get_user(args[0])
if not inviter:
raise CommandError("Unknown inviter")
if inviter.invitations > 0:
......
......@@ -66,6 +66,11 @@ class Command(BaseCommand):
dest='noadmin',
default=False,
help="Revoke user's admin rights"),
make_option('--inactive',
action='store_true',
dest='inactive',
default=False,
help="Change user's state to inactive"),
)
def handle(self, *args, **options):
......@@ -92,4 +97,6 @@ class Command(BaseCommand):
if options['renew_token']:
user.renew_token()
user.save()
if options.get('inactive'):
user.is_active = False
user.save()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment