コード例 #1
0
ファイル: admin.py プロジェクト: amitagrawal/pysis
    def delete_accounts_from_google(self, request, queryset):
        """Deletes the user from Google Apps database
        """
        gam = GoogleAppsManager()

        opts = self.model._meta
        app_label = opts.app_label
    
        deletable_objects = [profile for profile in queryset] 
    
        # The user has already confirmed the deletion.
        # Do the deletion and return a None to display the change list view again.
        if request.POST.get('post'):
            for profile in queryset:
                try:
                    gam.delete_account(profile.user.username)
                    profile.google_account_created = False
                    profile.save()
                except Exception, e:
                    messages.error(request,
                        'Error while deleting %s. Error : %s' %
                        (profile.register_number, e))
                else:
                    messages.success(request,
                        'Successfully deleted %s' % profile.register_number)
            return None
コード例 #2
0
ファイル: admin.py プロジェクト: soumyavuppala/pysis
    def delete_accounts_from_google(self, request, queryset):
        """Deletes the user from Google Apps database
        """
        gam = GoogleAppsManager()

        opts = self.model._meta
        app_label = opts.app_label

        deletable_objects = [profile for profile in queryset]

        # The user has already confirmed the deletion.
        # Do the deletion and return a None to display the change list view again.
        if request.POST.get('post'):
            for profile in queryset:
                try:
                    gam.delete_account(profile.user.username)
                    profile.google_account_created = False
                    profile.save()
                except Exception, e:
                    messages.error(
                        request, 'Error while deleting %s. Error : %s' %
                        (profile.register_number, e))
                else:
                    messages.success(
                        request,
                        'Successfully deleted %s' % profile.register_number)
            return None
コード例 #3
0
ファイル: forms.py プロジェクト: soumyavuppala/pysis
    def save(self):
        username = self.user.username
        password = self.cleaned_data['new_password1']

        gam = GoogleAppsManager()
        gam.change_password(username, password)

        return self.user
コード例 #4
0
ファイル: forms.py プロジェクト: FashtimeDotCom/pysis
    def save(self):
        username = self.user.username
        password = self.cleaned_data['new_password1']

        gam = GoogleAppsManager()
        gam.change_password(username,
                            password)

        return self.user
コード例 #5
0
ファイル: admin.py プロジェクト: amitagrawal/pysis
 def reactivate_account(self, request, queryset):
     gam = GoogleAppsManager()
     
     for profile in queryset:
         try:
             gam.unsuspend_user(profile.user.username)
             profile.active = True
             profile.save()
         except Exception, e:
             messages.error(request,
                 'Error while reactivating %s. Reason : %s' %
                 (profile.user.username, e))
         else:
             messages.success(request,
                 'Reactivated %s' % profile.user.username)            
コード例 #6
0
ファイル: admin.py プロジェクト: soumyavuppala/pysis
    def reactivate_account(self, request, queryset):
        gam = GoogleAppsManager()

        for profile in queryset:
            try:
                gam.unsuspend_user(profile.user.username)
                profile.active = True
                profile.save()
            except Exception, e:
                messages.error(
                    request, 'Error while reactivating %s. Reason : %s' %
                    (profile.user.username, e))
            else:
                messages.success(request,
                                 'Reactivated %s' % profile.user.username)
コード例 #7
0
ファイル: accounts_manager.py プロジェクト: amitagrawal/pysis
def create_account_in_google_apps(request, profile, password):

    username = profile.user.username
    first_name = profile.user.first_name
    last_name = profile.user.last_name
    college_email_id = profile.college_email_id
    nickname = college_email_id.split('@')[0]

    if profile.course.name == 'Staff':
        groupname = 'staff'
    else:
        groupname = profile.register_number[:5]

    if not college_email_id:
        messages.error(request,
             'College Email Id is empty for %s' % username)
        return

    if profile.google_account_created:
        messages.error(request,
             'College Email Id is already created for %s' % username)
        return

    try:
        gam = GoogleAppsManager()

        gam.create_account(username,
                           password,
                           first_name,
                           last_name,
                           nickname,
                           groupname
                          )

        send_introduction_mail(first_name, college_email_id)

        profile.google_account_created = True
        profile.save()

    except Exception, e:
        messages.error(request,
            'Error while creating %s. Error : %s' %
            (profile.register_number, e))
コード例 #8
0
ファイル: admin.py プロジェクト: soumyavuppala/pysis
    def create_accounts_in_google(self, request, queryset):
        """Creates the Google Apps account for the user
        """
        gam = GoogleAppsManager()
        password = User.objects.make_random_password(
            length=8, allowed_chars='0123456789')

        for profile in queryset:
            accounts_manager.create_account_in_google_apps(
                request, profile, password)
コード例 #9
0
ファイル: admin.py プロジェクト: amitagrawal/pysis
    def reset_password(self, request, queryset):
        gam = GoogleAppsManager()
        passwd = User.objects.make_random_password(length=6)

        for profile in queryset:
            if not profile.google_account_created:
                messages.error(request,
                    'No Google Apps account for %s' % profile.register_number)
                continue

            try:
                username = profile.register_number
                result = gam.change_password(username,
                                             passwd)
            except Exception, e:
                messages.error(request,
                    'Failed to update password for %s. Reason : %s' %
                    (username, e))
            else:
                messages.success(request,
                    'Successfully updated password for %s. New Password is %s' %
                    (username, passwd))
コード例 #10
0
def create_account_in_google_apps(request, profile, password):

    username = profile.user.username
    first_name = profile.user.first_name
    last_name = profile.user.last_name
    college_email_id = profile.college_email_id
    nickname = college_email_id.split('@')[0]

    if profile.course.name == 'Staff':
        groupname = 'staff'
    else:
        groupname = profile.register_number[:5]

    if not college_email_id:
        messages.error(request, 'College Email Id is empty for %s' % username)
        return

    if profile.google_account_created:
        messages.error(request,
                       'College Email Id is already created for %s' % username)
        return

    try:
        gam = GoogleAppsManager()

        gam.create_account(username, password, first_name, last_name, nickname,
                           groupname)

        send_introduction_mail(first_name, college_email_id)

        profile.google_account_created = True
        profile.save()

    except Exception, e:
        messages.error(
            request, 'Error while creating %s. Error : %s' %
            (profile.register_number, e))
コード例 #11
0
ファイル: admin.py プロジェクト: soumyavuppala/pysis
    def reset_password(self, request, queryset):
        gam = GoogleAppsManager()
        passwd = User.objects.make_random_password(length=8,
                                                   allowed_chars='0123456789')

        for profile in queryset:
            if not profile.google_account_created:
                messages.error(
                    request,
                    'No Google Apps account for %s' % profile.register_number)
                continue

            try:
                username = profile.register_number
                result = gam.change_password(username, passwd)
            except Exception, e:
                messages.error(
                    request, 'Failed to update password for %s. Reason : %s' %
                    (username, e))
            else:
                messages.success(
                    request,
                    'Successfully updated password for %s. New Password is %s'
                    % (username, passwd))