openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #23129
[Merge] lp:~springermac/openlp/fix-ups into lp:openlp
Jonathan Springer has proposed merging lp:~springermac/openlp/fix-ups into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~springermac/openlp/fix-ups/+merge/215942
Fixes first time wizard to use url and paths in web config file
Fixes PEP8 error in servicemanager
Add tests for first time form
--
https://code.launchpad.net/~springermac/openlp/fix-ups/+merge/215942
Your team OpenLP Core is requested to review the proposed merge of lp:~springermac/openlp/fix-ups into lp:openlp.
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py 2014-03-20 19:10:31 +0000
+++ openlp/core/ui/firsttimeform.py 2014-04-15 18:53:48 +0000
@@ -67,7 +67,7 @@
title = config.get('theme_%s' % theme, 'title')
filename = config.get('theme_%s' % theme, 'filename')
screenshot = config.get('theme_%s' % theme, 'screenshot')
- urllib.request.urlretrieve('%s%s' % (self.parent().web, screenshot),
+ urllib.request.urlretrieve('%s%s' % (self.parent().themes_url, screenshot),
os.path.join(gettempdir(), 'openlp', screenshot))
item = QtGui.QListWidgetItem(title, self.parent().themes_list_widget)
item.setData(QtCore.Qt.UserRole, filename)
@@ -96,6 +96,10 @@
if self.web_access:
files = self.web_access.read()
self.config.read_string(files.decode())
+ self.web = self.config.get('general', 'base url')
+ self.songs_url = self.web + self.config.get('songs', 'directory') + '/'
+ self.bibles_url = self.web + self.config.get('bibles', 'directory') + '/'
+ self.themes_url = self.web + self.config.get('themes', 'directory') + '/'
self.update_screen_list_combo()
self.was_download_cancelled = False
self.theme_screenshot_thread = None
@@ -341,7 +345,7 @@
item = self.songs_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole)
- size = self._get_file_size('%s%s' % (self.web, filename))
+ size = self._get_file_size('%s%s' % (self.songs_url, filename))
self.max_progress += size
# Loop through the Bibles list and increase for each selected item
iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget)
@@ -350,7 +354,7 @@
item = iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
filename = item.data(0, QtCore.Qt.UserRole)
- size = self._get_file_size('%s%s' % (self.web, filename))
+ size = self._get_file_size('%s%s' % (self.bibles_url, filename))
self.max_progress += size
iterator += 1
# Loop through the themes list and increase for each selected item
@@ -359,7 +363,7 @@
item = self.themes_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole)
- size = self._get_file_size('%s%s' % (self.web, filename))
+ size = self._get_file_size('%s%s' % (self.themes_url, filename))
self.max_progress += size
if self.max_progress:
# Add on 2 for plugins status setting plus a "finished" point.
@@ -435,7 +439,7 @@
self._increment_progress_bar(self.downloading % filename, 0)
self.previous_size = 0
destination = os.path.join(songs_destination, str(filename))
- self.url_get_file('%s%s' % (self.web, filename), destination)
+ self.url_get_file('%s%s' % (self.songs_url, filename), destination)
# Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(
self.bibles_tree_widget)
@@ -445,7 +449,7 @@
bible = item.data(0, QtCore.Qt.UserRole)
self._increment_progress_bar(self.downloading % bible, 0)
self.previous_size = 0
- self.url_get_file('%s%s' % (self.web, bible), os.path.join(bibles_destination, bible))
+ self.url_get_file('%s%s' % (self.bibles_url, bible), os.path.join(bibles_destination, bible))
bibles_iterator += 1
# Download themes
for i in range(self.themes_list_widget.count()):
@@ -454,7 +458,7 @@
theme = item.data(QtCore.Qt.UserRole)
self._increment_progress_bar(self.downloading % theme, 0)
self.previous_size = 0
- self.url_get_file('%s%s' % (self.web, theme), os.path.join(themes_destination, theme))
+ self.url_get_file('%s%s' % (self.themes_url, theme), os.path.join(themes_destination, theme))
# Set Default Display
if self.display_combo_box.currentIndex() != -1:
Settings().setValue('core/monitor', self.display_combo_box.currentIndex())
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2014-03-20 19:10:31 +0000
+++ openlp/core/ui/maindisplay.py 2014-04-15 18:53:48 +0000
@@ -350,7 +350,6 @@
self.hide_display(self.hide_mode)
# Only continue if the visibility wasn't changed during method call.
elif was_visible == self.isVisible():
-
# Single screen active
if self.screens.display_count == 1:
# Only make visible if setting enabled.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2014-04-14 18:28:04 +0000
+++ openlp/core/ui/servicemanager.py 2014-04-15 18:53:48 +0000
@@ -235,7 +235,8 @@
self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'),
icon=':/general/general_edit.png', triggers=self.remote_edit)
self.rename_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Rename...'),
- icon=':/general/general_edit.png', triggers=self.on_service_item_rename)
+ icon=':/general/general_edit.png',
+ triggers=self.on_service_item_rename)
self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'),
icon=':/general/general_edit.png',
triggers=self.on_service_item_edit_form)
=== added file 'tests/functional/openlp_core_ui/test_firsttimeform.py'
--- tests/functional/openlp_core_ui/test_firsttimeform.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_ui/test_firsttimeform.py 2014-04-15 18:53:48 +0000
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+"""
+Package to test the openlp.core.ui.firsttimeform package.
+"""
+from unittest import TestCase
+
+from tests.functional import MagicMock
+
+from tests.helpers.testmixin import TestMixin
+from openlp.core.common import Registry
+from openlp.core.ui.firsttimeform import FirstTimeForm
+
+
+class TestFirstTimeForm(TestCase, TestMixin):
+
+ def setUp(self):
+ screens = MagicMock()
+ self.get_application()
+ Registry.create()
+ Registry().register('application', self.app)
+ self.first_time_form = FirstTimeForm(screens)
+
+ def test_access_to_config(self):
+ """
+ Test if we can access the First Time Form's config file
+ """
+ # GIVEN A new First Time Form instance.
+
+ # WHEN The default First Time Form is built.
+
+ # THEN The First Time Form web configuration file should be accessable.
+ self.assertTrue(self.first_time_form.web_access,
+ 'First Time Wizard\'s web configuration file should be available')
+
+ def test_parsable_config(self):
+ """
+ Test if the First Time Form's config file is parsable
+ """
+ # GIVEN A new First Time Form instance.
+
+ # WHEN The default First Time Form is built.
+
+ # THEN The First Time Form web configuration file should be parsable
+ self.assertTrue(self.first_time_form.songs_url,
+ 'First Time Wizard\'s web configuration file should be parsable')
Follow ups