forked from openlp/openlp
Fix author<->songs relation
bzr-revno: 2420
This commit is contained in:
commit
24e082cbf0
@ -31,8 +31,6 @@ The :mod:`db` module provides the database and schema that is the backend for
|
|||||||
the Songs plugin
|
the Songs plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from sqlalchemy import Column, ForeignKey, Table, types
|
from sqlalchemy import Column, ForeignKey, Table, types
|
||||||
from sqlalchemy.orm import mapper, relation, reconstructor
|
from sqlalchemy.orm import mapper, relation, reconstructor
|
||||||
from sqlalchemy.sql.expression import func, text
|
from sqlalchemy.sql.expression import func, text
|
||||||
@ -329,7 +327,9 @@ def init_schema(url):
|
|||||||
Column('topic_id', types.Integer(), ForeignKey('topics.id'), primary_key=True)
|
Column('topic_id', types.Integer(), ForeignKey('topics.id'), primary_key=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
mapper(Author, authors_table)
|
mapper(Author, authors_table, properties={
|
||||||
|
'songs': relation(Song, secondary=authors_songs_table, viewonly=True)
|
||||||
|
})
|
||||||
mapper(AuthorSong, authors_songs_table, properties={
|
mapper(AuthorSong, authors_songs_table, properties={
|
||||||
'author': relation(Author)
|
'author': relation(Author)
|
||||||
})
|
})
|
||||||
@ -339,7 +339,8 @@ def init_schema(url):
|
|||||||
# Use the authors_songs relation when you need access to the 'author_type' attribute
|
# Use the authors_songs relation when you need access to the 'author_type' attribute
|
||||||
# or when creating new relations
|
# or when creating new relations
|
||||||
'authors_songs': relation(AuthorSong, cascade="all, delete-orphan"),
|
'authors_songs': relation(AuthorSong, cascade="all, delete-orphan"),
|
||||||
'authors': relation(Author, secondary=authors_songs_table, viewonly=True),
|
# Use lazy='joined' to always load authors when the song is fetched from the database (bug 1366198)
|
||||||
|
'authors': relation(Author, secondary=authors_songs_table, viewonly=True, lazy='joined'),
|
||||||
'book': relation(Book, backref='songs'),
|
'book': relation(Book, backref='songs'),
|
||||||
'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight),
|
'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight),
|
||||||
'topics': relation(Topic, backref='songs', secondary=songs_topics_table)
|
'topics': relation(Topic, backref='songs', secondary=songs_topics_table)
|
||||||
|
@ -195,9 +195,9 @@ class TestUi(TestCase):
|
|||||||
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
|
self.assertEqual(0, mocked_action.setIconVisibleInMenu.call_count,
|
||||||
'setIconVisibleInMenu should not have been called')
|
'setIconVisibleInMenu should not have been called')
|
||||||
|
|
||||||
def create_checked_enabled_visible_action_test(self):
|
def create_checked_disabled_invisible_action_test(self):
|
||||||
"""
|
"""
|
||||||
Test creating an action with the 'checked', 'enabled' and 'visible' properties.
|
Test that an invisible, disabled, checked action is created correctly
|
||||||
"""
|
"""
|
||||||
# GIVEN: A dialog
|
# GIVEN: A dialog
|
||||||
dialog = QtGui.QDialog()
|
dialog = QtGui.QDialog()
|
||||||
@ -206,9 +206,22 @@ class TestUi(TestCase):
|
|||||||
action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)
|
action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False)
|
||||||
|
|
||||||
# THEN: These properties should be set
|
# THEN: These properties should be set
|
||||||
self.assertEqual(True, action.isChecked())
|
self.assertTrue(action.isChecked(), 'The action should be checked')
|
||||||
self.assertEqual(False, action.isEnabled())
|
self.assertFalse(action.isEnabled(), 'The action should be disabled')
|
||||||
self.assertEqual(False, action.isVisible())
|
self.assertFalse(action.isVisible(), 'The action should be invisble')
|
||||||
|
|
||||||
|
def create_action_separator_test(self):
|
||||||
|
"""
|
||||||
|
Test creating an action as separator
|
||||||
|
"""
|
||||||
|
# GIVEN: A dialog
|
||||||
|
dialog = QtGui.QDialog()
|
||||||
|
|
||||||
|
# WHEN: We create an action as a separator
|
||||||
|
action = create_action(dialog, 'my_action', separator=True)
|
||||||
|
|
||||||
|
# THEN: The action should be a separator
|
||||||
|
self.assertTrue(action.isSeparator(), 'The action should be a separator')
|
||||||
|
|
||||||
def create_valign_selection_widgets_test(self):
|
def create_valign_selection_widgets_test(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user