The author_type column is part of the primary key and thus can't be NULL

This commit is contained in:
Samuel Mehrbrodt 2014-03-30 19:38:26 +02:00
parent 87051a094a
commit c7358e4a9f
4 changed files with 7 additions and 12 deletions

View File

@ -214,12 +214,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties):
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm', 'You need to type in at least one verse.'))
return False
if self.authors_list_view.count() == 0:
self.song_tab_widget.setCurrentIndex(1)
self.authors_list_view.setFocus()
critical_error_message_box(
message=translate('SongsPlugin.EditSongForm', 'You need to have an author for this song.'))
return False
if self.verse_order_edit.text():
result = self._validate_verse_list(self.verse_order_edit.text(), self.verse_list_widget.rowCount())
if not result:

View File

@ -35,7 +35,7 @@ import re
from sqlalchemy import Column, ForeignKey, Table, types
from sqlalchemy.orm import mapper, relation, reconstructor
from sqlalchemy.sql.expression import func
from sqlalchemy.sql.expression import func, text
from openlp.core.lib.db import BaseModel, init_db
from openlp.core.utils import get_natural_key
@ -259,7 +259,7 @@ def init_schema(url):
'authors_songs', metadata,
Column('author_id', types.Integer(), ForeignKey('authors.id'), primary_key=True),
Column('song_id', types.Integer(), ForeignKey('songs.id'), primary_key=True),
Column('author_type', types.String(), primary_key=True)
Column('author_type', types.String(), primary_key=True, nullable=False, server_default=text('""'))
)
# Definition of the "songs_topics" table

View File

@ -234,8 +234,8 @@ class SongMediaItem(MediaManagerItem):
if song.temporary:
continue
author_list = [author.display_name for author in song.authors]
song_title = str(song.title)
song_detail = '%s (%s)' % (song_title, create_separated_list(author_list))
song_detail = '%s (%s)' % (song.title, create_separated_list(author_list)) if author_list\
else '%s'%song.title
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)

View File

@ -102,7 +102,8 @@ def upgrade_4(session, metadata):
"""
Version 4 upgrade.
This upgrade adds a column for author type to the authors table
This upgrade adds a column for author type to the authors_songs table
"""
op = get_upgrade_op(session)
op.add_column('authors_songs', Column('author_type', types.String(), primary_key=True, server_default=null()))
op.add_column('authors_songs', Column('author_type', types.String(), primary_key=True,
nullable=False, server_default=text('""')))