예제 #1
0
 def handle(self, *args, **options):
     if 'filename' not in options:
         self.stdout.write("You have to specify filename")
         return
     else:
         file_user = open(options['filename'], 'r')
         # Expected: user1, user2, ..., user_n
         usernames = file_user.read().replace('\n', '').split(',')
         print usernames
         for name in usernames:
             username = name.strip()
             email = None
             try:
                 user = User.objects.get(username=username)
                 email = user.email
             except:
                 self.stdout.write(
                     "User with username {} doesn't exist".format(username))
             if email:
                 url_parts = settings.PLP_URL.split('://')
                 sso_url = 'https://sso.{0}'.format(url_parts[1])
                 send_change_email(user, email, sso_url)
                 self.stdout.write(
                     "Email sent for user {0} address {1}".format(
                         username, email))
예제 #2
0
파일: views.py 프로젝트: mico/npoed-sso-edx
 def post(self, request, *args, **kwargs):
     self.object = self.get_object()
     form_class = self.get_form_class()
     form = self.get_form(form_class)
     if form.is_valid():
         return self.form_valid(form)
     else:
         email = request.POST.get('email')
         if Site._meta.installed:
             site = Site.objects.get_current()
         else:
             site = RequestSite(request)
         if email != self.object.email:
             send_change_email(self.object, email, site, request=request)
         return self.form_invalid(form)
예제 #3
0
 def post(self, request, *args, **kwargs):
     self.object = self.get_object()
     form_class = self.get_form_class()
     form = self.get_form(form_class)
     if form.is_valid():
         return self.form_valid(form)
     else:
         email = request.POST.get('email')
         if Site._meta.installed:
             site = Site.objects.get_current()
         else:
             site = RequestSite(request)
         if email != self.object.email:
             send_change_email(self.object, email, site, request=request)
         return self.form_invalid(form)
예제 #4
0
 def handle(self, *args, **options):
     if 'filename' not in options:
         self.stdout.write("You have to specify filename")
         return
     else:
         file_user = open(options['filename'], 'r')
         # Expected: user1, user2, ..., user_n
         usernames = file_user.read().replace('\n','').split(',')
         print usernames
         for name in usernames:
             username = name.strip()
             email = None
             try:
                 user = User.objects.get(username=username)
                 email = user.email
             except:
                 self.stdout.write("User with username {} doesn't exist".format(username))
             if email:
                 url_parts = settings.PLP_URL.split('://')
                 sso_url = 'https://sso.{0}'.format(url_parts[1])
                 send_change_email(user, email, sso_url)
                 self.stdout.write("Email sent for user {0} address {1}".format(username, email))