Example #1
0
 def clean(self):
     query = self.cleaned_data.get('query')
     data = PubMed.get_data_from_query(query)
     count = int(data["Count"])
     limit = PubMed.get_query_limit()
     if count >= limit:
         raise forms.ValidationError("""Your query returned %d papers.
                                     It must return fewer than %d papers.
                                     Modify your query and try again.""" % (count, limit))
     elif count == 0:
         raise forms.ValidationError("Your query did not return any papers.")
     return self.cleaned_data
Example #2
0
def populate():
    jill = add_user("jill")
    bob = add_user("bob")
    jen = add_user("jen")

    # TODO: add a few more reviews
    adhd = add_review(users=[jill, bob],
                      title="Investigating the effects of acupuncture on children with ADHD",
                      description="The purpose of this review is to identify any potential positive or negative "
                                  "effects when applying the practice of acupuncture to young children suffering from "
                                  "attention deficit hyperactivity disorder, which is more commonly referred to by its abbreviation, ADHD.",
                      date_created=generate_random_date(),
                      last_modified=generate_random_date(recent=True),
                      query="""(adhd OR adhs OR addh) AND (child OR adolescent) AND acupuncture""")

    lung_cancer = add_review(users=[jen],
                             title="Development of lung cancer from inhalation of soldering fumes",
                             description="This review will retrieve all papers discussing links between soldering fume "
                                         "inhalation and lung cancer.",
                             date_created=generate_random_date(),
                             last_modified=generate_random_date(recent=True),
                             query="(solder OR soldering) AND (lung AND cancer)")

    rsi = add_review(users=[jen, bob],
                     title="RSI in musicians such as drummers and guitarists",
                     description="This review explores any connection between the development of repetitive strain "
                                 "injury, which is more commonly known as RSI, in musicians, or more specifically, "
                                 "people who play drums or play guitar. This issue is more frequently discussed in "
                                 "the world of computer use and office life, but rarely in the performance of music.",
                     date_created=generate_random_date(),
                     last_modified=generate_random_date(recent=True),
                     query="(RSI OR repetitive OR strain OR injury) AND (drums OR drumming OR drummer OR guitar OR guitarist)")

    stress = add_review(users=[jill],
                        title="Stress experienced by students during examinations",
                        description="This review will retrieve all medical papers which discuss the issues regarding "
                                    "stress, anxiety, and a general lack of wellbeing of students while their "
                                    "educational establishment undergo examinations.",
                        date_created=generate_random_date(),
                        last_modified=generate_random_date(recent=True),
                        query="stress AND anxiety AND student AND (exam OR examination OR test) AND (university OR college)")

    reviews = [
        adhd,
        lung_cancer,
        rsi,
        stress,
    ]

    import time

    for review in reviews:
        start = time.time()

        Paper.create_papers_from_pubmed_ids(PubMed.get_ids_from_query(review.query), review)

        end = time.time()
        duration = (end - start)
        print "Populating %s took %f seconds" % (review.title, duration)