From 935293621febdc873650744dec5faaeaa2595a6e Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Tue, 15 Sep 2020 09:35:55 +0500 Subject: [PATCH] bug fix: improve size for smtphost --- cloudAPI/cloudManager.py | 24 +++++++++++++++++++++--- emailMarketing/models.py | 4 ++-- plogical/upgrade.py | 10 ++++++++++ userManagment/views.py | 19 +++++++++++++++++++ 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index ffab613c2..fd134fb60 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -62,13 +62,30 @@ class CloudManager: try: try: - selectedACL = ACL.objects.get(name='user') + UserAccountName = self.data['UserAccountName'] UserPassword = self.data['UserPassword'] FullName = self.data['FullName'] token = hashPassword.generateToken(UserAccountName, UserPassword) password = hashPassword.hash_password(UserPassword) + try: + initWebsitesLimit = int(self.data['websitesLimit']) + except: + initWebsitesLimit = 10 + + try: + acl = self.data['acl'] + selectedACL = ACL.objects.get(name=acl) + + except: + selectedACL = ACL.objects.get(name='user') + + try: + apiAccess = int(self.data['api']) + except: + apiAccess = 10 + try: newAdmin = Administrator(firstName=FullName, lastName="", @@ -76,10 +93,11 @@ class CloudManager: type=3, userName=UserAccountName, password=password, - initWebsitesLimit=10, + initWebsitesLimit=initWebsitesLimit, owner=1, acl=selectedACL, - token=token + token=token, + api=apiAccess ) newAdmin.save() except BaseException as msg: diff --git a/emailMarketing/models.py b/emailMarketing/models.py index f0b7e991d..b352f2549 100755 --- a/emailMarketing/models.py +++ b/emailMarketing/models.py @@ -29,8 +29,8 @@ class SMTPHosts(models.Model): owner = models.ForeignKey(Administrator, on_delete=models.CASCADE) host = models.CharField(max_length=150, unique= True) port = models.CharField(max_length=10) - userName = models.CharField(max_length=50) - password = models.CharField(max_length=50) + userName = models.CharField(max_length=200) + password = models.CharField(max_length=200) class EmailTemplate(models.Model): owner = models.ForeignKey(Administrator, on_delete=models.CASCADE) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 59ea20a62..a5b0dba7d 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -622,6 +622,16 @@ imap_folder_list_limit = 0 except: pass + try: + cursor.execute("ALTER TABLE emailMarketing_smtphosts MODIFY userName varchar(200)") + except: + pass + + try: + cursor.execute("ALTER TABLE emailMarketing_smtphosts MODIFY password varchar(200)") + except: + pass + try: cursor.execute("ALTER TABLE websiteFunctions_backups MODIFY fileName varchar(200)") except: diff --git a/userManagment/views.py b/userManagment/views.py index 3550cb813..3c5b8c56a 100755 --- a/userManagment/views.py +++ b/userManagment/views.py @@ -438,12 +438,31 @@ def submitUserDeletion(request): accountUsername = data['accountUsername'] + try: + force = data['force'] + except: + force = 0 + + currentACL = ACLManager.loadedACL(userID) currentUser = Administrator.objects.get(pk=userID) userInQuestion = Administrator.objects.get(userName=accountUsername) + if ACLManager.checkUserOwnerShip(currentACL, currentUser, userInQuestion): + + + if force: + userACL = ACLManager.loadedACL(userInQuestion.pk) + websitesName = ACLManager.findAllSites(userACL, userInQuestion.pk) + + from websiteFunctions.website import WebsiteManager + wm = WebsiteManager() + + for website in websitesName: + wm.submitWebsiteDeletion(userID, {'websiteName': website}) + user = Administrator.objects.get(userName=accountUsername) childUsers = Administrator.objects.filter(owner=user.pk)