Skip to content

API - UI_Front.functions

UI_Front.functions.select_functions

select_functions

Functions

filter_recover_data(post_data)

If cancel and return to the page of selection with all filter. We recuperate data so can write them in the html page input : dictionnary with key in format= "filter_X_Y" X is the numero of the filter and Y the numero of element in the filter value is a string. The format of each string is "Type:data_type;name_value:value;" for data_type = topic -> "Type:topic;topic_name:name_of_topic" name of topic is in format [A-Za-z0-9_,-\s]+ . for data_type = author -> "Type:author;name:name;" name format is [A-Za-z0-9-\s_]. It can be without name for data_type = keyword -> "Type:keyword;keyword:value;" the value can be [A-Za-z0-9-\s_] for data_type = neighbour -> "Type:neighbour;DOI:value;

output : dictionnary of dictionnary. each dictionnary is a filter block and have the keys:topic,author,keyword and doi. each of them is a list of value

filters_manager(research, post_data)

We first give the research object. We secondly give the dictionnary with post data and return a dictionnary: input: dictionnary with key in format= "filter_X_Y" X is the numero of the filter and Y the numero of the element in the filter. value is a string. The format of each string is "Type:data_type;name_value:value;" for data_type = topic -> "Type:topic;topic_name:name_of_topic;" name of topic is in format [A-Za-z0-9_,-\s]+ . for data_type = author -> "Type:author;name:name;" name format is [A-Za-z0-9-\s_]. It can be without name for data_type = keyword -> "Type:keyword;keyword:value;" the value can be [A-Za-z0-9-\s_] for data_type = neighbour -> "Type:neighbour;DOI:value;"

output: dictionnary in this format dict["filter_[0-9]+"] . The key represent the name of a filter and the value is a dictionnary in this format: dict["type of value"] = list of these value. type of value = 'topic', value = ["topic1","topic2",etc...], topic name type of value = 'author', value = a list of the Author objects that name match with last_name and/or first_name match type of value = 'keyword', value = ["key1","key2",etc...] type of value = 'neighbour' value = [article_object that has the same doi in input]

get_articles_filtered(research, filters)

The function take the research id and filters, build a list of article who match the filters and return the list of the article id. If choose id instead of the object,this is to save it in user session as a list of integer.

input: dictionnary in this format dict["filter_[0-9]+"] . The key represent the name of a filter and the value is a dictionnary in this format: dict["type of value"] = list of these value. type of value = 'topic', value = ["topic1","topic2",etc...], topic name type of value = 'author', value = a list of the Author objects that last_name and/or first_name match type of value = 'keyword', value = ["key1","key2",etc...] type of value = 'neighbour' value = [article_object that has the same doi in input]

output: list of objects of Article

UI_Front.functions.tablechoice_functions

tablechoice_functions

Functions

all_display_table_choice(user, research)

Reset all article so can display all article

download_finalcsv(research, user)

Return a csv file as attachment.

Parameters:

Name Type Description Default
research Research object Model database
   The research object model where is used to store
   search query, status and related data.
required
user User

A User object related with the data of the user.

required

Returns:

Name Type Description
response HttpResponse

A csv file as attachment.

reset_table_choice(user, research)

To reset, delete all row who have been added and put to_display to true

update_article_is_check_table_choice(user, research, list_id)

The function take a list of id object of TableChoice row and user. All row who is in list_id, the boolean 'is_check' will be put to True. The function take user id by security. We check if all id in 'list_id' is owned by user because, the list of id come from the front-end by the user

update_article_to_display_table_choice(user, research, list_id)

The function take a list of id object of TableChoice row and user. All row who is not in list_id, the boolean 'to_display' will be put to False. The function take user id by security. We check if all id in 'list_id' is owned by user because, the list of id come from the front-end by the user

update_neighbour_table_choice(user, research)

With an initial list of article from all row who are to_display True, add the nearest neighbour of these article in table choice.

update_new_table_choice(user, research, article_id_list)

When user make a new research filtering, the ancients are deleted and the new are written

UI_Front.functions.user_page_functions

user_page_functions

UI_Front.functions.utils_functions

utils_functions

Functions

neighbour_article(article, research)

Return a list of article but there isn't the center article in the list.

The function take an article, a research and process with cluster object, the nearest neighbor. By default, take the 5 nearest. by iteration, search around the article +-100 and if doesn't have enough, the same but with +-200 around. We make max +-1000.

UI_Front.functions.welcome_functions

welcome_functions

Functions

sort_historical(research_dict, sort_type)

Take a dictionary key: id of research, value: list of Keywords objects. Return a list sorted in this format: [(id research,[string keywords])]. For the sort type, it has 'pertinence', 'article+' and 'article-'

word_list(string_to_parse)

From a search string that was control if there is bad characters, extract all keywords and return them