Skip to content

Commit

Permalink
updating to MonthlyContributorsError
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Nov 13, 2024
1 parent 8b102b5 commit c28c7c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Mergin/configuration_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
this_dir = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(this_dir, "mergin_client.whl")
sys.path.append(path)
from mergin.client import MerginClient, ClientError, LoginError
from .mergin.client import MerginClient, ClientError, LoginError

from .utils import (
get_mergin_auth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtGui import QDesktopServices

ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "ui_project_limit_hit_dialog.ui")
ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "ui", "ui_monthly_contributors_error_dialog.ui.ui")

class ProjectLimitHitDialog(QDialog):
class MonthlyContributorsErrorDialog(QDialog):
def __init__(self, e, parent=None):
QDialog.__init__(self, parent)
self.ui = uic.loadUi(ui_file, self)
Expand Down
14 changes: 9 additions & 5 deletions Mergin/projects_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from .mergin.merginproject import MerginProject
from .project_status_dialog import ProjectStatusDialog
from .project_limit_hit_dialog import ProjectLimitHitDialog
from .monthly_contributors_error_dialog import MonthlyContributorsErrorDialog


class MerginProjectsManager(object):
Expand Down Expand Up @@ -97,14 +97,18 @@ def create_project(self, project_name, project_dir, is_public, namespace):
if e.http_error == 409:
msg = f'Project named "{project_name}" already exists in the workspace "{namespace}".\nPlease try renaming the project.'
elif e.server_code == ErrorCode.ProjectsLimitHit.value:
dlg = ProjectLimitHitDialog(e)
dlg.exec()
return False
msg = (
"Maximum number of projects reached. Please upgrade your subscription to create new projects.\n"
f"Projects quota: {e.server_response['projects_quota']}"
)
elif e.server_code == ErrorCode.StorageLimitHit.value:
msg = (
f"{e.detail}\nCurrent limit: {bytes_to_human_size(dlg.exception.server_response['storage_limit'])}"
)

elif e.server_code == ErrorCode.MonthlyContributorsError.value:
dlg = MonthlyContributorsErrorDialog(e)
dlg.exec()
return False
QMessageBox.critical(None, "Create Project", "Failed to create Mergin Maps project.\n" + msg)
return False
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Project Limit Hit</string>
<string>Monthly Contributors Error</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down Expand Up @@ -155,7 +155,7 @@ for the limit to reset.</string>
</sizepolicy>
</property>
<property name="text">
<string>Used</string>
<string>Monthly Contributors</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit c28c7c2

Please sign in to comment.