Skip to content
Snippets Groups Projects
Commit 5ff086b9 authored by inso's avatar inso
Browse files

Added renew membership + warning when leaving a community

parent c616f262
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,19 @@
<property name="topMargin">
<number>5</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_quality">
<property name="text">
......@@ -67,7 +80,14 @@
<item>
<widget class="QPushButton" name="button_membership">
<property name="text">
<string>Send membership demand</string>
<string>Renew membership</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_leaving">
<property name="text">
<string>Send leaving demand</string>
</property>
</widget>
</item>
......@@ -92,8 +112,8 @@
<slot>send_membership_demand()</slot>
<hints>
<hint type="sourcelabel">
<x>289</x>
<y>277</y>
<x>198</x>
<y>335</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
......@@ -102,14 +122,14 @@
</hints>
</connection>
<connection>
<sender>button_membership</sender>
<sender>button_leaving</sender>
<signal>clicked()</signal>
<receiver>CommunityTabWidget</receiver>
<slot>send_membership_leaving()</slot>
<hints>
<hint type="sourcelabel">
<x>289</x>
<y>277</y>
<x>338</x>
<y>335</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
......
......@@ -13,6 +13,7 @@ from ..gen_resources.community_tab_uic import Ui_CommunityTabWidget
from .add_contact import AddContactDialog
from .wot_tab import WotTabWidget
from .transfer import TransferMoneyDialog
from .password_asker import PasswordAskerDialog
from .certification import CertificationDialog
from ..tools.exceptions import PersonNotFoundError, NoPeerAvailable
......@@ -33,14 +34,12 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
self.account = account
self.password_asker = password_asker
self.list_community_members.setModel(MembersListModel(community))
self.button_membership.disconnect()
if self.account.member_of(self.community):
self.button_membership.setText("Send leaving demand")
self.button_membership.clicked.connect(self.send_membership_leaving)
self.button_membership.setText("Renew membership")
else:
self.button_membership.setText("Send membership demand")
self.button_membership.clicked.connect(self.send_membership_demand)
self.button_leaving.hide()
self.tabs_information.addTab(WotTabWidget(account, community,
password_asker),
......@@ -121,23 +120,29 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
QMessageBox.Ok)
def send_membership_leaving(self):
password = self.password_asker.ask()
if password == "":
return
try:
self.account.send_membership(password, self.community, 'OUT')
QMessageBox.information(self, "Membership",
"Success sending leaving demand")
except ValueError as e:
QMessageBox.critical(self, "Leaving demand error",
e.message)
except NoPeerAvailable as e:
QMessageBox.critical(self, "Network error",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
reply = QMessageBox.warning(self, "Warning",
"""Are you sure ?
Sending a membership demand cannot be canceled.
The process to join back the community later will have to be done again."""
.format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel)
if reply == QMessageBox.Ok:
password = PasswordAskerDialog(self.app.current_account).ask()
if password == "":
return
try:
self.account.send_membership(password, self.community, 'OUT')
QMessageBox.information(self, "Membership",
"Success sending leaving demand")
except ValueError as e:
QMessageBox.critical(self, "Leaving demand error",
e.message)
except NoPeerAvailable as e:
QMessageBox.critical(self, "Network error",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
......@@ -175,9 +175,9 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
Person.lookup(self.account.pubkey, self.community, cached=False)
except PersonNotFoundError as e:
reply = QMessageBox.question(self, "Pubkey not found",
"The public key of your account wasn't found in the community. :\n \
{0}\n \
Would you like to publish the key ?".format(self.account.pubkey))
"""The public key of your account wasn't found in the community. :\n
{0}\n
Would you like to publish the key ?""".format(self.account.pubkey))
if reply == QMessageBox.Yes:
password = self.password_asker.ask()
if password == "":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment