예제 #1
0
파일: accounts.py 프로젝트: yuan1024/sentry
    def __init__(self, user, request, *args, **kwargs):
        self.user = user
        self.request = request
        super(AccountSettingsForm, self).__init__(*args, **kwargs)

        needs_password = user.has_usable_password()

        if self.user.is_managed:
            # username and password always managed, email and
            # name optionally managed
            for field in ('email', 'name', 'username'):
                if field == 'username' or field in settings.SENTRY_MANAGED_USER_FIELDS:
                    self.fields[field] = ReadOnlyTextField(label=self.fields[field].label)
                if field == 'email':
                    needs_password = False

            del self.fields['new_password']
            del self.fields['verify_new_password']

        # don't show username field if its the same as their email address
        if self.user.email == self.user.username:
            del self.fields['username']

        if not needs_password:
            del self.fields['password']
    def __init__(self, user, *args, **kwargs):
        self.user = user
        super(AccountSettingsForm, self).__init__(*args, **kwargs)

        if self.user.is_managed:
            # username and password always managed, email and
            # first_name optionally managed
            for field in ('email', 'first_name', 'username'):
                if field == 'username' or field in settings.SENTRY_MANAGED_USER_FIELDS:
                    self.fields[field] = ReadOnlyTextField(label=self.fields[field].label)
            # don't show password field at all
            del self.fields['new_password']

        # don't show username field if its the same as their email address
        if self.user.email == self.user.username:
            del self.fields['username']
예제 #3
0
 def __init__(self, *args, **kwargs):
     super(ChangeUserForm, self).__init__(*args, **kwargs)
     self.user = kwargs['instance']
     if self.user.is_managed:
         self.fields['username'] = ReadOnlyTextField(
             label="Username (managed)")