def addSuggestedList(self, text, focussedField):
		"""
		This functions gets suggestions to be added for remote and keyboard both.
		"""
		focussedField.removeAllItems()
		items = []
		# Get suggestions from Database.
		if len(text) >= 1:
			items += SearchLogic.suggestSearch(text, focussedField.name)
		else:
			return False
		# Get suggestions from Jazzy.
		lastWord = text.split()[-1]
		if len(lastWord) >= 3:
			phonetic_items = self.getSuggestions(lastWord)
			for p in phonetic_items:
				q = str(p)
				if q not in items and len(q) >= len(lastWord):
					items.append(q)
		# Add suggestions to Drop Down list.
		focussedField.addItem(text)
		for item in items:
			if item != text:
				focussedField.addItem(item)
		focussedField.setPopupVisible(False)
		focussedField.setMaximumRowCount(8)
		focussedField.setPopupVisible(True)
		if len(items) == 0:
			return False
		else:
			return True
 def buttonPressedAction(self, buttonName):
     if buttonName == "Search":
         if self.mode == 0:
             texts = [self.defaultField.getEditor().getEditorComponent().text]
         elif self.mode == 1:
             texts = [
                 self.nameField.getEditor().getEditorComponent().text,
                 self.subjectField.getEditor().getEditorComponent().text,
                 self.authorField.getEditor().getEditorComponent().text,
                 self.classField.getEditor().getEditorComponent().text,
             ]
         text = SearchLogic.getValidText(texts)
         print(text)
         # Can't call SearchLogic.finalSearch in this file. This is Jython that is Python.
         # It uses MySQLdb which does not work with Jython.
         self.exit()
     elif buttonName == "Cancel":
         print("Cancel")
         self.exit()
     elif buttonName == "Advanced":
         print("Advanced")
         if self.mode == 0:
             self.win.visible = False
             self.secondSearch()
         elif self.mode == 1:
             self.win.visible = False
             self.thirdSearch()
         elif self.mode == 2:
             self.win.visible = False
             self.firstSearch()
     else:
         pass  # This case may come
 def addSuggestedList(self, text, focussedField):
     items = []
     # Get suggestions from Database.
     if len(text) >= 3:
         items += SearchLogic.suggestSearch(text, focussedField.name)
     print(items)
     # Get suggestions from Jazzy.
     lastWord = text.split()[-1]
     if len(lastWord) >= 3:
         phonetic_items = self.getSuggestions(lastWord)
         print(phonetic_items)
         for p in phonetic_items:
             q = str(p)
             if q not in items and len(q) >= len(lastWord):
                 items.append(q)
                 # Add suggestions to Drop Down list.
     self.focussedField.addItem(text)
     for item in items:
         if item != text:
             self.focussedField.addItem(item)
     self.focussedField.setPopupVisible(False)
     self.focussedField.setMaximumRowCount(8)
     self.focussedField.setPopupVisible(True)
     if len(items) == 0:
         return False
     else:
         return True
	def buttonPressedAction(self, buttonName):
		"""
		This function performs functionality for button press,
		for both Keyboard and Remote. For Keyboard it is accessed through
		buttonPressed function and for Remote it is directly accessed.
		It is needed as Remote does not generate an event.
		"""
		if buttonName == 'Search':
			texts = []
			mode = self.tabbedPane.getSelectedIndex()
			if mode == 0:
				texts = [self.defaultField.getEditor().getEditorComponent().text]
			elif mode == 1:
				texts = [self.nameField_1.getEditor().getEditorComponent().text, \
						self.subjectField_1.getEditor().getEditorComponent().text, \
						self.authorField_1.getEditor().getEditorComponent().text, \
						self.classField_1.getSelectedItem()]
			elif mode == 2:
				texts = [self.nameField_2.getEditor().getEditorComponent().text, \
						self.subjectField_2.getEditor().getEditorComponent().text, \
						self.authorField_2.getEditor().getEditorComponent().text, \
						self.classField_2.getSelectedItem(), \
						self.descriptionField.text, \
						self.contentTypeField.getSelectedItem(), self.videoResField.getSelectedItem(), \
						self.otherMediaTextField.text, self.otherLangField.text, \
						self.uploadedAfterYear.getSelectedItem(), self.uploadedAfterMonth.getSelectedItem(), \
						self.uploadedAfterDay.getSelectedItem(), self.uploadedBeforeYear.getSelectedItem(), \
						self.uploadedBeforeMonth.getSelectedItem(), self.uploadedBeforeDay.getSelectedItem(), \
						self.contentDurationButtonGroup.getSelection().getActionCommand(), \
						self.contentDurationHour.getSelectedItem(), \
						self.contentDurationMinute.getSelectedItem(), self.uploadedByField.text, \
						self.objectIDField.text, self.subject_list, self.media_list, self.lang_list]
			text = SearchLogic.getValidText(texts)
			print(text, mode)
			self.exit()
			# Can't call SearchLogic.finalSearch in this file. This is Jython that is Python. 
			# It uses MySQLdb which does not work with Jython.
		elif buttonName == 'Cancel':
			print('Cancel', -1)
			self.exit()
		elif buttonName == 'Clear':
			self.contentDurationRadio_2.setSelected(True)
		else:
			pass									# This case may come
예제 #5
0
def search():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        key_word = request.form['keyword']
        number = request.form['pagesize']
    elif request.method == 'GET':
        username = request.args.get('username')
        password = request.args.get('password')
        key_word = request.args.get('keyword')
        number = request.args.get('pagesize')
    else:
        return json.dumps(())
    result = check_user_info(username, password, True)
    if result['status'] == False:
        return json.dumps(result)
    if key_word is None or key_word == '':
        return json.dumps(())
    results = SearchLogic.get_processed_title(key_word, number)
    result['list'] = results
    return json.dumps(result)