From e04b4d7a2f94119afb2212e1db28aec56ee54870 Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Mon, 30 Mar 2020 20:32:52 +0200 Subject: [PATCH] DRY principle - example cluster add calculation --- src/message/simple_edits.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/message/simple_edits.py b/src/message/simple_edits.py index f9e3658..25ea3a8 100644 --- a/src/message/simple_edits.py +++ b/src/message/simple_edits.py @@ -3,6 +3,7 @@ from message.simple_messages import NoReset, DataChgClickMessage import message.common_accessors as common_accessors from browser import document from model import Sense, Example +from model.example_clusters import ExampleClusters class QuestionMessage(Message): @@ -111,12 +112,6 @@ class ExampleClusterAdd(DataChgClickMessage): def update_model(self, model): example = self.get_arg(0, Example) - max_example_cluster_num = 0 - for sense in model.entry.senses: - for ex in sense.examples: - cnum = ex.get_cluster() - if cnum is not None: - max_example_cluster_num = max(max_example_cluster_num, cnum) - + max_example_cluster_num = ExampleClusters.first_empty_cluster() example.set_cluster(max_example_cluster_num + 1)