500 """<b>Run Testserver</b>""" |
502 """<b>Run Testserver</b>""" |
501 """<p>Run a development server with data from a set of fixtures.</p>""" |
503 """<p>Run a development server with data from a set of fixtures.</p>""" |
502 )) |
504 )) |
503 self.runTestServerAct.triggered[()].connect(self.__runTestServer) |
505 self.runTestServerAct.triggered[()].connect(self.__runTestServer) |
504 self.actions.append(self.runTestServerAct) |
506 self.actions.append(self.runTestServerAct) |
|
507 |
|
508 def __initAuthorizationActions(self): |
|
509 """ |
|
510 Private method to define the authorization actions. |
|
511 """ |
|
512 self.changePasswordAct = E5Action(self.trUtf8('Change Password'), |
|
513 self.trUtf8('Change &Password'), |
|
514 0, 0, |
|
515 self,'django_auth_changepassword') |
|
516 self.changePasswordAct.setStatusTip(self.trUtf8( |
|
517 'Change the password of a user')) |
|
518 self.changePasswordAct.setWhatsThis(self.trUtf8( |
|
519 """<b>Change Password</b>""" |
|
520 """<p>Change the password of a user of the Django project.</p>""" |
|
521 )) |
|
522 self.changePasswordAct.triggered[()].connect(self.__changePassword) |
|
523 self.actions.append(self.changePasswordAct) |
|
524 |
|
525 self.createSuperUserAct = E5Action(self.trUtf8('Create Superuser'), |
|
526 self.trUtf8('Create &Superuser'), |
|
527 0, 0, |
|
528 self,'django_auth_createsuperuser') |
|
529 self.createSuperUserAct.setStatusTip(self.trUtf8( |
|
530 'Create a superuser account')) |
|
531 self.createSuperUserAct.setWhatsThis(self.trUtf8( |
|
532 """<b>Create Superuser</b>""" |
|
533 """<p>Create a superuser account for the Django project.</p>""" |
|
534 )) |
|
535 self.createSuperUserAct.triggered[()].connect(self.__createSuperUser) |
|
536 self.actions.append(self.createSuperUserAct) |
|
537 |
|
538 def __initSessionActions(self): |
|
539 """ |
|
540 Private method to define the session actions. |
|
541 """ |
|
542 self.clearSessionsAct = E5Action(self.trUtf8('Clear Sessions'), |
|
543 self.trUtf8('Clear &Sessions'), |
|
544 0, 0, |
|
545 self,'django_session_clearsessions') |
|
546 self.clearSessionsAct.setStatusTip(self.trUtf8( |
|
547 'Clear expired sessions')) |
|
548 self.clearSessionsAct.setWhatsThis(self.trUtf8( |
|
549 """<b>Clear Sessions</b>""" |
|
550 """<p>Clear expired sessions of the Django project.</p>""" |
|
551 )) |
|
552 self.clearSessionsAct.triggered[()].connect(self.__clearSessions) |
|
553 self.actions.append(self.clearSessionsAct) |
505 |
554 |
506 def initMenu(self): |
555 def initMenu(self): |
507 """ |
556 """ |
508 Public slot to initialize the Django menu. |
557 Public slot to initialize the Django menu. |
509 |
558 |
609 menu.addAction(self.dumpDataAct) |
662 menu.addAction(self.dumpDataAct) |
610 menu.addAction(self.loadDataAct) |
663 menu.addAction(self.loadDataAct) |
611 menu.addSeparator() |
664 menu.addSeparator() |
612 menu.addAction(self.runTestAct) |
665 menu.addAction(self.runTestAct) |
613 menu.addAction(self.runTestServerAct) |
666 menu.addAction(self.runTestServerAct) |
|
667 |
|
668 return menu |
|
669 |
|
670 def __initAuthorizationMenu(self): |
|
671 """ |
|
672 Private slot to initialize the authorization menu. |
|
673 |
|
674 @return the menu generated (QMenu) |
|
675 """ |
|
676 menu = QMenu(self.trUtf8("&Authorization"), self.__ui) |
|
677 menu.setTearOffEnabled(True) |
|
678 |
|
679 menu.addAction(self.changePasswordAct) |
|
680 menu.addAction(self.createSuperUserAct) |
|
681 |
|
682 return menu |
|
683 |
|
684 def __initSessionMenu(self): |
|
685 """ |
|
686 Private slot to initialize the authorization menu. |
|
687 |
|
688 @return the menu generated (QMenu) |
|
689 """ |
|
690 menu = QMenu(self.trUtf8("&Session"), self.__ui) |
|
691 menu.setTearOffEnabled(True) |
|
692 |
|
693 menu.addAction(self.clearSessionsAct) |
614 |
694 |
615 return menu |
695 return menu |
616 |
696 |
617 ################################################################## |
697 ################################################################## |
618 ## methods below implement the various hook related functions |
698 ## methods below implement the various hook related functions |
1695 QTimer.singleShot(2000, self.__testServerProc.kill) |
1775 QTimer.singleShot(2000, self.__testServerProc.kill) |
1696 self.__testServerProc.waitForFinished(3000) |
1776 self.__testServerProc.waitForFinished(3000) |
1697 self.__testServerProc = None |
1777 self.__testServerProc = None |
1698 |
1778 |
1699 ################################################################## |
1779 ################################################################## |
|
1780 ## slots below implement authorization functions |
|
1781 ################################################################## |
|
1782 |
|
1783 def __changePassword(self): |
|
1784 """ |
|
1785 Private slot to change the password of a user. |
|
1786 """ |
|
1787 consoleCmd = self.__isSpawningConsole( |
|
1788 self.__plugin.getPreferences("ConsoleCommandNoClose"))[1] |
|
1789 if consoleCmd: |
|
1790 userName, ok = QInputDialog.getText( |
|
1791 self.__ui, |
|
1792 self.trUtf8("Change Password"), |
|
1793 self.trUtf8("Enter the name of the user:"), |
|
1794 QLineEdit.Normal) |
|
1795 if ok and userName != "": |
|
1796 args = Utilities.parseOptionString(consoleCmd) |
|
1797 args[0] = Utilities.getExecutablePath(args[0]) |
|
1798 args.append(self.__getPythonExecutable()) |
|
1799 args.append("manage.py") |
|
1800 args.append("changepassword") |
|
1801 args.append(userName) |
|
1802 try: |
|
1803 wd = self.__sitePath() |
|
1804 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
|
1805 if not started: |
|
1806 E5MessageBox.critical(None, |
|
1807 self.trUtf8('Process Generation Error'), |
|
1808 self.trUtf8('The Django process could not be started.')) |
|
1809 except DjangoNoSiteSelectedException: |
|
1810 pass |
|
1811 |
|
1812 def __createSuperUser(self): |
|
1813 """ |
|
1814 Private slot to create a super user account. |
|
1815 """ |
|
1816 consoleCmd = self.__isSpawningConsole( |
|
1817 self.__plugin.getPreferences("ConsoleCommandNoClose"))[1] |
|
1818 if consoleCmd: |
|
1819 args = Utilities.parseOptionString(consoleCmd) |
|
1820 args[0] = Utilities.getExecutablePath(args[0]) |
|
1821 args.append(self.__getPythonExecutable()) |
|
1822 args.append("manage.py") |
|
1823 args.append("createsuperuser") |
|
1824 try: |
|
1825 wd = self.__sitePath() |
|
1826 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
|
1827 if not started: |
|
1828 E5MessageBox.critical(None, |
|
1829 self.trUtf8('Process Generation Error'), |
|
1830 self.trUtf8('The Django process could not be started.')) |
|
1831 except DjangoNoSiteSelectedException: |
|
1832 pass |
|
1833 |
|
1834 ################################################################## |
|
1835 ## slots below implement session functions |
|
1836 ################################################################## |
|
1837 |
|
1838 def __clearSessions(self): |
|
1839 """ |
|
1840 Private slot to clear expired sessions. |
|
1841 """ |
|
1842 title = self.trUtf8("Clear Sessions") |
|
1843 |
|
1844 try: |
|
1845 wd = self.__sitePath() |
|
1846 except DjangoNoSiteSelectedException: |
|
1847 return |
|
1848 |
|
1849 args = [] |
|
1850 args.append(self.__getPythonExecutable()) |
|
1851 args.append("manage.py") |
|
1852 args.append("clearsessions") |
|
1853 |
|
1854 dia = DjangoDialog(title, |
|
1855 msgSuccess = self.trUtf8("Expired sessions cleared successfully.")) |
|
1856 res = dia.startProcess(args, wd) |
|
1857 if res: |
|
1858 dia.exec_() |
|
1859 |
|
1860 ################################################################## |
1700 ## slots below implement translation functions |
1861 ## slots below implement translation functions |
1701 ################################################################## |
1862 ################################################################## |
1702 |
1863 |
1703 def __getLocale(self, filename): |
1864 def __getLocale(self, filename): |
1704 """ |
1865 """ |