From 9f2961c9a380fd9dca1d00114df5b47aee1c5713 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 27 Nov 2014 19:38:13 +0100 Subject: [PATCH] [qcineoob] protection against same-person movies in common and same-movie persons in common --- weboob/applications/qcineoob/movie.py | 17 +++++++++++++---- weboob/applications/qcineoob/person.py | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/weboob/applications/qcineoob/movie.py b/weboob/applications/qcineoob/movie.py index e4176689..febc391d 100644 --- a/weboob/applications/qcineoob/movie.py +++ b/weboob/applications/qcineoob/movie.py @@ -20,7 +20,7 @@ import urllib 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.capabilities.base import empty @@ -129,6 +129,15 @@ class Movie(QFrame): my_title = self.movie.original_title other_id = unicode(self.ui.personsInCommonEdit.text()).split('@')[0] other_movie = self.backend.get_movie(other_id) - 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]) + if other_id == self.movie.id: + QMessageBox.critical(None, self.tr('"Persons in common" error'), + 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]) diff --git a/weboob/applications/qcineoob/person.py b/weboob/applications/qcineoob/person.py index 6be2bcb6..400570f0 100644 --- a/weboob/applications/qcineoob/person.py +++ b/weboob/applications/qcineoob/person.py @@ -20,7 +20,7 @@ import urllib 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.capabilities.base import empty @@ -94,6 +94,15 @@ class Person(QFrame): my_name = self.person.name other_id = unicode(self.ui.moviesInCommonEdit.text()).split('@')[0] other_person = self.backend.get_person(other_id) - 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]) + if other_id == self.person.id: + QMessageBox.critical(None, self.tr('"Moviess in common" error'), + 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])