[qcineoob] protection against same-person movies in common and same-movie persons in common

This commit is contained in:
Julien Veyssier 2014-11-27 19:38:13 +01:00 committed by Romain Bignon
commit 9f2961c9a3
2 changed files with 26 additions and 8 deletions

View file

@ -20,7 +20,7 @@
import urllib import urllib
from PyQt4.QtCore import Qt, SIGNAL from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QImage, QPixmap from PyQt4.QtGui import QFrame, QImage, QPixmap, QMessageBox
from weboob.applications.qcineoob.ui.movie_ui import Ui_Movie from weboob.applications.qcineoob.ui.movie_ui import Ui_Movie
from weboob.capabilities.base import empty from weboob.capabilities.base import empty
@ -129,6 +129,15 @@ class Movie(QFrame):
my_title = self.movie.original_title my_title = self.movie.original_title
other_id = unicode(self.ui.personsInCommonEdit.text()).split('@')[0] other_id = unicode(self.ui.personsInCommonEdit.text()).split('@')[0]
other_movie = self.backend.get_movie(other_id) other_movie = self.backend.get_movie(other_id)
other_title = other_movie.original_title if other_id == self.movie.id:
desc = 'Persons in common %s, %s'%(my_title, other_title) QMessageBox.critical(None, self.tr('"Persons in common" error'),
self.parent.doAction(desc, self.parent.personsInCommonAction, [self.backend.name, my_id, other_id]) unicode(self.tr('Nice try\nThe movies must be different')),
QMessageBox.Ok)
elif not other_movie:
QMessageBox.critical(None, self.tr('"Persons in common" error'),
unicode(self.tr('Movie not found: %s' % other_id)),
QMessageBox.Ok)
else:
other_title = other_movie.original_title
desc = 'Persons in common %s, %s'%(my_title, other_title)
self.parent.doAction(desc, self.parent.personsInCommonAction, [self.backend.name, my_id, other_id])

View file

@ -20,7 +20,7 @@
import urllib import urllib
from PyQt4.QtCore import SIGNAL, Qt from PyQt4.QtCore import SIGNAL, Qt
from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication, QMessageBox
from weboob.applications.qcineoob.ui.person_ui import Ui_Person from weboob.applications.qcineoob.ui.person_ui import Ui_Person
from weboob.capabilities.base import empty from weboob.capabilities.base import empty
@ -94,6 +94,15 @@ class Person(QFrame):
my_name = self.person.name my_name = self.person.name
other_id = unicode(self.ui.moviesInCommonEdit.text()).split('@')[0] other_id = unicode(self.ui.moviesInCommonEdit.text()).split('@')[0]
other_person = self.backend.get_person(other_id) other_person = self.backend.get_person(other_id)
other_name = other_person.name if other_id == self.person.id:
desc = 'Movies in common %s, %s'%(my_name, other_name) QMessageBox.critical(None, self.tr('"Moviess in common" error'),
self.parent.doAction(desc, self.parent.moviesInCommonAction, [self.backend.name, my_id, other_id]) unicode(self.tr('Nice try\nThe persons must be different')),
QMessageBox.Ok)
elif not other_person:
QMessageBox.critical(None, self.tr('"Movies in common" error'),
unicode(self.tr('Person not found: %s' % other_id)),
QMessageBox.Ok)
else:
other_name = other_person.name
desc = 'Movies in common %s, %s'%(my_name, other_name)
self.parent.doAction(desc, self.parent.moviesInCommonAction, [self.backend.name, my_id, other_id])