1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

is_manually_set_contact_email (#5702)

* is_manually_set_contact_email

* update profile sql
This commit is contained in:
欢乐马
2024-09-10 12:24:15 +08:00
committed by GitHub
parent acbd02d071
commit 604175e5e3
5 changed files with 8 additions and 1 deletions

View File

@@ -75,3 +75,5 @@ CREATE TABLE IF NOT EXISTS `sdoc_operation_log` (
ALTER TABLE share_fileshare ADD COLUMN IF NOT EXISTS `user_scope` varchar(225) DEFAULT 'all_users'; ALTER TABLE share_fileshare ADD COLUMN IF NOT EXISTS `user_scope` varchar(225) DEFAULT 'all_users';
ALTER TABLE share_fileshare ADD COLUMN IF NOT EXISTS `authed_details` LONGTEXT DEFAULT NULL; ALTER TABLE share_fileshare ADD COLUMN IF NOT EXISTS `authed_details` LONGTEXT DEFAULT NULL;
ALTER TABLE profile_profile ADD COLUMN IF NOT EXISTS `is_manually_set_contact_email` tinyint(1) DEFAULT 0;

View File

@@ -1043,6 +1043,8 @@ class CustomLDAPBackend(object):
if nickname: if nickname:
Profile.objects.add_or_update(username, nickname=nickname) Profile.objects.add_or_update(username, nickname=nickname)
if contact_email: if contact_email:
p = Profile.objects.get_profile_by_user(username)
if not (p and p.is_manually_set_contact_email):
Profile.objects.add_or_update(username, contact_email=contact_email) Profile.objects.add_or_update(username, contact_email=contact_email)
except Exception as e: except Exception as e:
logger.error(f'update ldap user failed {e}') logger.error(f'update ldap user failed {e}')

View File

@@ -56,3 +56,4 @@ class DetailedProfileForm(ProfileForm):
contact_email = self.cleaned_data['contact_email'] contact_email = self.cleaned_data['contact_email']
Profile.objects.update_contact_email(username, contact_email) Profile.objects.update_contact_email(username, contact_email)
Profile.objects.filter(user=username).update(is_manually_set_contact_email=True)

View File

@@ -165,6 +165,7 @@ class Profile(models.Model):
login_id = models.CharField(max_length=225, unique=True, null=True, blank=True) login_id = models.CharField(max_length=225, unique=True, null=True, blank=True)
# Contact email is used to receive emails. # Contact email is used to receive emails.
contact_email = models.EmailField(max_length=225, unique=True, null=True, blank=True) contact_email = models.EmailField(max_length=225, unique=True, null=True, blank=True)
is_manually_set_contact_email = models.BooleanField(default=False)
institution = models.CharField(max_length=225, db_index=True, null=True, blank=True, default='') institution = models.CharField(max_length=225, db_index=True, null=True, blank=True, default='')
list_in_address_book = models.BooleanField(default=False, db_index=True) list_in_address_book = models.BooleanField(default=False, db_index=True)
objects = ProfileManager() objects = ProfileManager()

View File

@@ -749,6 +749,7 @@ CREATE TABLE `profile_profile` (
`lang_code` longtext, `lang_code` longtext,
`login_id` varchar(225) DEFAULT NULL, `login_id` varchar(225) DEFAULT NULL,
`contact_email` varchar(225) DEFAULT NULL, `contact_email` varchar(225) DEFAULT NULL,
`is_manually_set_contact_email` tinyint(1) DEFAULT 0,
`institution` varchar(225) DEFAULT NULL, `institution` varchar(225) DEFAULT NULL,
`list_in_address_book` tinyint(1) NOT NULL, `list_in_address_book` tinyint(1) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),