예제 #1
0
    def do_job(self):
        if not self.args.subject:
            print("Please specify a subject to rename")

        subject = Subject.query.filter(
            Subject.title == self.args.subject).first()
        if not subject:
            print('Subject can not found: %s' % self.args.subject)
            return

        new_subject = Subject.query.filter(
            Subject.title == self.args.new_name).first()
        if new_subject:
            print("There is already a subject with name: %s" %
                  self.args.new_name)
            answer = input("Do you want to merge these subjects? [Y/n]: ")
            if not answer or answer.lower() == 'y':
                for task in subject.tasks:
                    task.subject = new_subject
                DBSession.flush()
                DBSession.delete(subject)
                DBSession.commit()
            else:
                print('Operation aborted by user.')

        else:
            subject.title = self.args.new_name
            DBSession.commit()
예제 #2
0
    def do_job(self):
        if not self.args.subject:
            print("Please specify a subject to rename")

        subject = Subject.query.filter(Subject.title == self.args.subject).first()
        if not subject:
            print('Subject can not found: %s' % self.args.subject)
            return

        new_subject = Subject.query.filter(Subject.title == self.args.new_name).first()
        if new_subject:
            print("There is already a subject with name: %s" % self.args.new_name)
            answer = raw_input("Do you want to merge these subjects? [Y/n]: ")
            if not answer or answer.lower() == 'y':
                for task in subject.tasks:
                    task.subject = new_subject
                DBSession.flush()
                DBSession.delete(subject)
                DBSession.commit()
            else:
                print('Operation aborted by user.')

        else:
            subject.title = self.args.new_name
            DBSession.commit()
예제 #3
0
 def do_job(self):
     active_task = Task.get_active_task()
     if active_task:
         print('Aborting active task: %s' % active_task)
         DBSession.delete(active_task)
         DBSession.commit()
     else:
         print("You don't have any active task")
예제 #4
0
    def do_job(self):
        subject = Subject.query.filter(Subject.title == self.args.subject).first()
        if not subject:
            print 'Subject can not found: %s' % self.args.subject
        else:
            DBSession.delete(subject)
            DBSession.commit()

        print "Subject `%s` was deleted successfully" % self.args.subject
예제 #5
0
    def do_job(self):
        subject = Subject.query.filter(
            Subject.title == self.args.subject).first()
        if not subject:
            print('Subject can not found: %s' % self.args.subject)
        else:
            DBSession.delete(subject)
            DBSession.commit()

        print("Subject `%s` was deleted successfully" % self.args.subject)