def recompute_for_topics_and_languages():
    from zeeguu_core.model import Topic, Language

    for each in Topic.get_all_topics():
        each.all_articles()

    for each in Language.available_languages():
        each.get_articles()
Exemple #2
0
    def _localized_topic_keyword_in_url(self, topic: str, localized: str,
                                        keyword: str, url: str):
        topic = Topic(topic)
        localized_topic = LocalizedTopic(topic, self.user.learned_language,
                                         localized)
        localized_topic.keywords = keyword

        article = ArticleRule().article
        url = Url.find_or_create(self.db.session, url)
        article.url = url

        assert localized_topic.matches_article(article)
Exemple #3
0
def cache_articles(code):
    if code != zeeguu_core.app.config.get("PRIVATE_API_CODE"):
        return "Nope"

    from zeeguu_core.model import Topic, Language

    for each in Topic.get_all_topics():
        each.all_articles()

    for each in Language.available_languages():
        each.get_articles()

    return "OK"
Exemple #4
0
def subscribe_to_topic_with_id():
    """
    :param: topic_id -- the id of the topic to be subscribed to.
    Subscribe to the topic with the given id

    :return: "OK" in case of success
    """

    topic_id = int(request.form.get('topic_id', ''))

    topic_object = Topic.find_by_id(topic_id)
    TopicSubscription.find_or_create(session, flask.g.user, topic_object)

    return "OK"
Exemple #5
0
def subscribe_to_filter_with_id():
    """
    :param: filter_id -- the id of the filter to be subscribed to.
    Subscribe to the filter with the given id

    :return: "OK" in case of success
    """

    filter_id = int(request.form.get('filter_id', ''))

    filter_object = Topic.find_by_id(filter_id)
    TopicFilter.find_or_create(session, flask.g.user, filter_object)

    return "OK"
Exemple #6
0
def subscribe_to_topic_with_id():
    """
    :param: topic_id -- the id of the topic to be subscribed to.
    Subscribe to the topic with the given id

    :return: "OK" in case of success
    """

    topic_id = int(request.form.get('topic_id', ''))

    topic_object = Topic.find_by_id(topic_id)
    TopicSubscription.find_or_create(session, flask.g.user, topic_object)

    return "OK"
Exemple #7
0
def subscribe_to_filter_with_id():
    """
    :param: filter_id -- the id of the filter to be subscribed to.
    Subscribe to the filter with the given id

    :return: "OK" in case of success
    """

    filter_id = int(request.form.get('filter_id', ''))

    filter_object = Topic.find_by_id(filter_id)
    TopicFilter.find_or_create(session, flask.g.user, filter_object)

    return "OK"
Exemple #8
0
    def testDownloadWithTopic(self):
        feed = RSSFeedRule().feed1
        topic = Topic("Spiegel")
        zeeguu_core.db.session.add(topic)
        zeeguu_core.db.session.commit()
        loc_topic = LocalizedTopic(topic, self.lan, "spiegelDE", "spiegel")
        zeeguu_core.db.session.add(loc_topic)
        zeeguu_core.db.session.commit()

        download_from_feed(feed, zeeguu_core.db.session, 3)

        article = feed.get_articles(limit=2)[0]

        assert (topic in article.topics)
Exemple #9
0
def cache_articles(code):

    if code != zeeguu_core.app.config.get("PRIVATE_API_CODE"):
        return "Nope"

    from zeeguu_core.model import Topic, Language

    for each in Topic.get_all_topics():
        each.all_articles()

    for each in Language.available_languages():
        each.get_articles()

    print("done caching articles!")

    return "OK"
Exemple #10
0
def get_interesting_topics():
    """
    Get a list of interesting topics for the given language.
    Interesting topics are for now defined as:
        - The topic is not followed yet
        - The topic is not in the filters list

    :return:
    """
    topic_data = []
    already_filtered = [each.topic for each in TopicFilter.all_for_user(flask.g.user)]
    already_subscribed = [each.topic for each in TopicSubscription.all_for_user(flask.g.user)]

    for topic in Topic.get_all_topics():
        if (topic not in already_filtered) and (topic not in already_subscribed):
            topic_data.append(topic.as_dictionary())
    return json_result(topic_data)
Exemple #11
0
def get_interesting_topics():
    """
    Get a list of interesting topics for the given language.
    Interesting topics are for now defined as:
        - The topic is not followed yet
        - The topic is not in the filters list

    :return:
    """
    topic_data = []
    already_filtered = [
        each.topic for each in TopicFilter.all_for_user(flask.g.user)
    ]
    already_subscribed = [
        each.topic for each in TopicSubscription.all_for_user(flask.g.user)
    ]

    for topic in Topic.get_all_topics():
        if (topic not in already_filtered) and (topic
                                                not in already_subscribed):
            topic_data.append(topic.as_dictionary())
    return json_result(topic_data)
 def test_add_topic(self):
     health = Topic("health")
     sports = Topic("sports")
     self.article1.add_topic(health)
     self.article1.add_topic(sports)
     assert len(self.article1.topics) == 2