def event_related_objects(self):
        if self.related_objects is None:
            self.related_objects = list()
            for p in self.event_connected_projects.all().order_by(
                    'project_date_add'):
                r = RelatedObject(p.project_title, p.project_lead,
                                  p.project_image, p.project_date_add,
                                  'project', p.get_absolute_url())
                self.related_objects.append(r)

            for c in self.event_connected_competitions.all().order_by(
                    'competition_date_add'):
                r = RelatedObject(c.competition_title, c.competition_lead,
                                  c.competition_image, c.competition_date_add,
                                  'competition', c.get_absolute_url())
                self.related_objects.append(r)

            for d in self.event_connected_dissertations.all().order_by(
                    'dissertation_date_add'):
                r = RelatedObject(d.dissertation_title, d.dissertation_lead,
                                  d.dissertation_image,
                                  d.dissertation_date_add, 'dissertation',
                                  d.get_absolute_url())
                self.related_objects.append(r)

            self.related_objects.sort(key=lambda ro: ro.date_add, reverse=True)

        return self.related_objects
Beispiel #2
0
 def competition_related_objects(self):
     if self.related_objects is None:
         self.related_objects = list()
         for e in self.competition_connected_events.all().order_by('event_date_add'):
             r = RelatedObject(e.event_name, e.event_lead, e.event_poster, e.event_date_add, 'event',
                               e.get_absolute_url())
             self.related_objects.append(r)
         for p in self.competition_connected_projects.all().order_by('project_date_add'):
             r = RelatedObject(p.project_title, p.project_lead, p.project_image, p.project_date_add, 'project',
                               p.get_absolute_url())
             self.related_objects.append(r)
     
         self.related_objects.sort(key=lambda ro : ro.date_add, reverse=True)
     
     return self.related_objects
    def journalissue_similar_journalissues(self):
        if self.similar_journalissues is None:
            self.similar_journalissues = list()
            more_like_this_journalissues = SearchQuerySet().models(
                JournalIssue).more_like_this(self)
            i = 0
            for journalissue in more_like_this_journalissues:
                if journalissue.object is None:
                    continue
                title = journalissue.object.journalissue_journal.journal_title
                title = title + ' | '
                if journalissue.object.journalissue_volume:
                    title = title + journalissue.object.journalissue_volume
                if journalissue.object.journalissue_number:
                    title = title + '(' + journalissue.object.journalissue_number + ')'
                title = title + ' | '
                title = title + journalissue.object.journalissue_year
                b = RelatedObject(
                    title, journalissue.object.journalissue_lead,
                    journalissue.object.journalissue_image,
                    journalissue.object.journalissue_date_add, journalissue.
                    object.journalissue_category.publication_category_name,
                    journalissue.object.get_absolute_url(),
                    journalissue.object.journalissue_title)
                self.similar_journalissues.append(b)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES - 1:
                    break

        return self.similar_journalissues
    def book_similar_books(self):
        if self.similar_books is None:
            self.similar_books = list()
            more_like_this_books = SearchQuerySet().models(
                Book).more_like_this(self)
            i = 0
            for book in more_like_this_books:
                if book.object is None:
                    continue
                authors = [
                    a.person_first_name + ' ' + a.person_last_name
                    for a in book.object.book_authors.all()
                ]
                authors = ', '.join(authors)
                b = RelatedObject(
                    book.object.book_title, book.object.book_lead,
                    book.object.book_image, book.object.book_date_add,
                    book.object.book_category.publication_category_name,
                    book.object.get_absolute_url(), authors)
                self.similar_books.append(b)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_books
    def new_latest_news(self):
        if self.latest_news is None:
            self.latest_news = list()
            limited_latest_news = New.objects.filter(
                new_is_accepted=True).exclude(new_id=self.new_id).order_by(
                    '-new_date_add')[:MAX_NUMBER_OF_LATEST_NEWS]
            for new in limited_latest_news:
                image = new.new_image
                if new.new_related_event and new.new_related_event.event_poster:
                    image = new.new_related_event.event_poster
                if new.new_related_project and new.new_related_project.project_image:
                    image = new.new_related_project.project_image
                if new.new_related_dissertation and new.new_related_dissertation.dissertation_image:
                    image = new.new_related_dissertation.dissertation_image
                if new.new_related_competition and new.new_related_competition.competition_image:
                    image = new.new_related_competition.competition_image
                if new.new_related_joboffer and new.new_related_joboffer.joboffer_image:
                    image = new.new_related_joboffer.joboffer_image
                if new.new_related_eduoffer and new.new_related_eduoffer.eduoffer_image:
                    image = new.new_related_eduoffer.eduoffer_image
                if new.new_related_scholarship and new.new_related_scholarship.scholarship_image:
                    image = new.new_related_scholarship.scholarship_image
                if new.new_related_book and new.new_related_book.book_image:
                    image = new.new_related_book.book_image
                if new.new_related_journalissue and new.new_related_journalissue.journalissue_image:
                    image = new.new_related_journalissue.journalissue_image
                if new.new_related_article and new.new_related_article.article_image:
                    image = new.new_related_article.article_image
                c = RelatedObject(new.new_title, new.new_lead, image,
                                  new.new_date_add,
                                  new.new_category.new_category_item_name,
                                  new.get_absolute_url())
                self.latest_news.append(c)

        return self.latest_news
Beispiel #6
0
    def scholarship_related_objects(self):
        if self.related_objects is None:
            self.related_objects = list()
            for p in self.scholarship_connected_projects.all().order_by(
                    'project_date_add'):
                r = RelatedObject(p.project_title, p.project_lead,
                                  p.project_image, p.project_date_add,
                                  'project', p.get_absolute_url())
                self.related_objects.append(r)

            self.related_objects.sort(key=lambda ro: ro.date_add, reverse=True)

        return self.related_objects
Beispiel #7
0
 def competition_similar_competitions(self):
     if self.similar_competitions is None:
         self.similar_competitions = list()
         more_like_this_competitions = SearchQuerySet().models(Competition).more_like_this(self)
         i = 0;
         for competition in more_like_this_competitions:
             if competition.object is None:
                 continue
             c = RelatedObject(competition.object.competition_title, competition.object.competition_lead, competition.object.competition_image,
                               competition.object.competition_date_add, None, competition.object.get_absolute_url())
             self.similar_competitions.append(c)
             i = i + 1
             if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                 break
         
     return self.similar_competitions   
    def dissertation_similar_dissertations(self):
        if self.similar_dissertations is None:
            self.similar_dissertations = list()
            more_like_this_dissertations = SearchQuerySet().models(
                Dissertation).more_like_this(self)
            i = 0
            for dissertation in more_like_this_dissertations:
                if dissertation.object is None:
                    continue
                d = RelatedObject(dissertation.object.dissertation_title,
                                  dissertation.object.dissertation_lead,
                                  dissertation.object.dissertation_image,
                                  dissertation.object.dissertation_date_add,
                                  None, dissertation.object.get_absolute_url())
                self.similar_dissertations.append(d)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_dissertations
Beispiel #9
0
    def joboffer_similar_joboffers(self):
        if self.similar_joboffers is None:
            self.similar_joboffers = list()
            more_like_this_joboffers = SearchQuerySet().models(
                JobOffer).more_like_this(self)
            i = 0
            for joboffer in more_like_this_joboffers:
                if joboffer.object is None:
                    continue
                jo = RelatedObject(joboffer.object.joboffer_position,
                                   joboffer.object.joboffer_lead,
                                   joboffer.object.joboffer_image,
                                   joboffer.object.joboffer_date_add, None,
                                   joboffer.object.get_absolute_url())
                self.similar_joboffers.append(jo)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_joboffers
Beispiel #10
0
    def article_similar_articles(self):
        if self.similar_articles is None:
            self.similar_articles = list()
            more_like_this_articles = SearchQuerySet().models(
                Article).more_like_this(self)
            i = 0
            for article in more_like_this_articles:
                if article.object is None:
                    continue
                c = RelatedObject(article.object.article_title,
                                  article.object.article_lead,
                                  article.object.article_image,
                                  article.object.article_date_add, None,
                                  article.object.get_absolute_url())
                self.similar_articles.append(c)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_articles
    def event_similar_events(self):
        if self.similar_events is None:
            self.similar_events = list()
            more_like_this_events = SearchQuerySet().models(
                Event).more_like_this(self)
            i = 0
            for event in more_like_this_events:
                if event.object is None:
                    continue
                c = RelatedObject(event.object.event_name,
                                  event.object.event_lead,
                                  event.object.event_poster,
                                  event.object.event_date_add, None,
                                  event.object.get_absolute_url())
                self.similar_events.append(c)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_events
Beispiel #12
0
    def eduoffer_similar_eduoffers(self):
        if self.similar_eduoffers is None:
            self.similar_eduoffers = list()
            more_like_this_eduoffers = SearchQuerySet().models(
                EducationalOffer).more_like_this(self)
            i = 0
            for eduoffer in more_like_this_eduoffers:
                if eduoffer.object is None:
                    continue
                eo = RelatedObject(eduoffer.object.eduoffer_position,
                                   eduoffer.object.eduoffer_lead,
                                   eduoffer.object.eduoffer_image,
                                   eduoffer.object.eduoffer_date_add, None,
                                   eduoffer.object.get_absolute_url())
                self.similar_eduoffers.append(eo)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_eduoffers
    def project_similar_projects(self):
        if self.similar_projects is None:
            self.similar_projects = list()
            more_like_this_projects = SearchQuerySet().models(
                Project).more_like_this(self)
            i = 0
            for project in more_like_this_projects:
                if project.object is None:
                    continue
                p = RelatedObject(project.object.project_title,
                                  project.object.project_lead,
                                  project.object.project_image,
                                  project.object.project_date_add, None,
                                  project.object.get_absolute_url())
                self.similar_projects.append(p)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        return self.similar_projects
Beispiel #14
0
    def scholarship_similar_scholarships(self):
        if self.similar_scholarships is None:
            self.similar_scholarships = list()
            more_like_this_scholarships = SearchQuerySet().models(
                Scholarship).more_like_this(self)
            i = 0
            for scholarship in more_like_this_scholarships:
                if scholarship.object is None:
                    continue
                s = RelatedObject(scholarship.object.scholarship_name,
                                  scholarship.object.scholarship_lead,
                                  scholarship.object.scholarship_image,
                                  scholarship.object.scholarship_date_add,
                                  None, scholarship.object.get_absolute_url())
                self.similar_scholarships.append(s)
                i = i + 1
                if i >= MAX_NUMBER_OF_SIMILAR_ENTITIES:
                    break

        print(self.similar_scholarships)
        return self.similar_scholarships
    def project_related_objects(self):
        if self.related_objects is None:
            self.related_objects = list()
            for c in self.project_connected_competitions.all().order_by(
                    'competition_date_add'):
                r = RelatedObject(c.competition_title, c.competition_lead,
                                  c.competition_image, c.competition_date_add,
                                  'competition', c.get_absolute_url())
                self.related_objects.append(r)
            for d in self.project_connected_dissertations.all().order_by(
                    'dissertation_date_add'):
                r = RelatedObject(d.dissertation_title, d.dissertation_lead,
                                  d.dissertation_image,
                                  d.dissertation_date_add, 'dissertation',
                                  d.get_absolute_url())
                self.related_objects.append(r)
            for eo in self.project_connected_eduoffers.all().order_by(
                    'eduoffer_date_add'):
                r = RelatedObject(eo.eduoffer_position, eo.eduoffer_lead,
                                  eo.eduoffer_image, eo.eduoffer_date_add,
                                  'eduoffer', eo.get_absolute_url())
                self.related_objects.append(r)
            for e in self.project_connected_events.all().order_by(
                    'event_date_add'):
                r = RelatedObject(e.event_name, e.event_lead, e.event_poster,
                                  e.event_date_add, 'event',
                                  e.get_absolute_url())
                self.related_objects.append(r)
            for jo in self.project_connected_joboffers.all().order_by(
                    'joboffer_date_add'):
                r = RelatedObject(jo.joboffer_position, jo.joboffer_lead,
                                  jo.joboffer_image, jo.joboffer_date_add,
                                  'joboffer', jo.get_absolute_url())
                self.related_objects.append(r)
            for s in self.project_connected_scholarships.all().order_by(
                    'scholarship_date_add'):
                r = RelatedObject(s.scholarship_name, s.scholarship_lead,
                                  s.scholarship_image, s.scholarship_date_add,
                                  'scholarship', s.get_absolute_url())
                self.related_objects.append(r)

            self.related_objects.sort(key=lambda ro: ro.date_add, reverse=True)

        return self.related_objects