Example #1
0
def create_ratings():
    for trainer in Trainer.objects.all():
        for n in range(1, randrange(1, 890)):
            rating = randrange(1, 6)  # rating
            pokemon = Pokemon.objects.get(pokedex_id=n)
            r = Rating(trainer=trainer, pokemon=pokemon, rating=rating)
            r.save()
Example #2
0
def rate(request, project_id, rate):
    p=Project.objects.get(id=project_id)
    user=User.objects.get(login=request.session['login'])
    r=Rating()
    r.rating=rate
    r.user=user
    r.project=p
    r.save()
    try:
            rates=Rating.objects.filter(Q(project__id=int(p.id)))
    except:
            rates=None
    j=int(rates.__len__())
    rating=0
    for rate in rates:
        rating+=rate.rating
    if j!=0:
        rating = rating/j
    rating = int(rating)

    html='Ocena:<nobr>'
    for i in range(1,6):
        if i>int(rating):
            print(i)
            html += '<img width=\"20\" height=\"20\" src=\"/static/emptystarr.png\" >'
        else:
            print(i)
            html += '<img width=\"20\" height=\"20\" src=\"/static/fillstar.jpg\"  >'
    html+='</nobr><br>'
    print(html)
    return HttpResponse(html)
Example #3
0
def AddRating(rating):
    #	try:
    r = Rating(numsurveyed=rating["NumSurveyed"],
               numenrolled=rating["NumEnrolled"])
    r.coursewhole = Decimal(
        rating["Course"]) if len(rating["Course"]) > 0 else None
    r.coursecontent = Decimal(
        rating["Content"]) if len(rating["Content"]) > 0 else None
    r.instructoreffectiveness = Decimal(
        rating["Effectiveness"]) if len(rating["Effectiveness"]) > 0 else None
    r.instructorcontribution = Decimal(
        rating["Contrib"]) if len(rating["Contrib"]) > 0 else None
    r.instructorinterest = Decimal(
        rating["Interest"]) if len(rating["Interest"]) > 0 else None
    r.amountlearned = Decimal(
        rating["Learned"]) if len(rating["Learned"]) > 0 else None
    r.grading = Decimal(
        rating["Grading"]) if len(rating["Grading"]) > 0 else None

    #print r.coursewhole

    #print rating
    #print ",".join(rating.values())
    r.save()
    return r
Example #4
0
    def post(self, request, *args, **kwargs):
        try:
            data = json.loads(request.body)
            item = data['item']
            rating = data['rating']
            ts = int(time.time())

            rating_record = Rating(user=request.user.id,
                                   item=Item.objects.get(id=item),
                                   rating=rating,
                                   timestamp=ts)
            rating_record.save()
        except:
            return HttpResponse(status=500)
        return HttpResponse(status=200)
Example #5
0
 def put(request, id):
     user_id = auth.get_user(request).id
     rating_id = None
     try:
         rating_id = Rating.objects.get(user_id=user_id, book_id=id).id
     except Rating.DoesNotExist:
         pass
     print(request.info)
     rating = Rating(book_id=id,
                     user_id=user_id,
                     rating=request.info['rating'])
     rating.id = rating_id
     rating.save()
     time.sleep(1)
     return RestJsonResponse()
Example #6
0
def AddRating(rating):
#	try:
		r = Rating(numsurveyed = rating["NumSurveyed"], numenrolled = rating["NumEnrolled"])
		r.coursewhole = Decimal(rating["Course"]) if len(rating["Course"]) > 0 else None
		r.coursecontent = Decimal(rating["Content"]) if len(rating["Content"]) > 0 else None
		r.instructoreffectiveness = Decimal(rating["Effectiveness"]) if len(rating["Effectiveness"]) > 0 else None
		r.instructorcontribution = Decimal(rating["Contrib"]) if len(rating["Contrib"]) > 0 else None
		r.instructorinterest = Decimal(rating["Interest"]) if len(rating["Interest"]) > 0 else None
		r.amountlearned = Decimal(rating["Learned"]) if len(rating["Learned"]) > 0 else None
		r.grading = Decimal(rating["Grading"]) if len(rating["Grading"]) > 0 else None

		#print r.coursewhole

		#print rating
		#print ",".join(rating.values())
		r.save()
		return r
Example #7
0
prop6.save()
prop7.save()

gallery17 = Gallery(name="milngavie4_m2dtqt.jpg", property=prop2)
gallery17.save()
gallery18 = Gallery(name="milngavie3_memqjg.jpg", property=prop2)
gallery18.save()
gallery19 = Gallery(name="milngavie2_bdt0r4.jpg", property=prop2)
gallery19.save()
gallery20 = Gallery(name="milngavie1_cazxmk.jpg", property=prop2)
gallery20.save()
prop2.img = gallery17
prop2.save()

rating1 = Rating(score=1)
rating1.save()
rating2 = Rating(score=2)
rating2.save()
rating3 = Rating(score=3)
rating3.save()
rating4 = Rating(score=4)
rating4.save()
rating5 = Rating(score=5)
rating5.save()

review1 = Review(
    rating=rating1,
    user='******',
    description=
    'Very poor experience. The accomodation provided lacked general hygiene. Food was OK though, I just wish there was more.'
)