Exemple #1
0
def graph(professor):
    scores = []
    comments = Comment.objects.filter(professor=professor,
                                      responsibility__gt=0)
    for c in comments:
        scores.append(
            float(c.responsibility + c.personality + c.workload + c.difficulty)
            * 5)

    if len(scores) == 0:
        scores.append(0)
    if len(scores) == 1:
        scores.append(scores[0])

    chart = Sparkline(scores, encoding='text')
    chart.color('0077CC')
    chart.size(450, 262)
    chart.marker('B', 'E6F2FA', 0, 0, 0)
    chart.line(1, 0, 0)
    chart.axes('y')

    if not settings.DEBUG:
        client = CamoClient(settings.CAMO_URL, key=settings.CAMO_KEY)
        url = client.image_url(chart.url)
    else:
        url = chart.url

    return url
Exemple #2
0
def graph(professor):
    scores = []
    comments = Comment.objects.filter(
        professor=professor, responsibility__gt=0)
    for c in comments:
        scores.append(float(c.responsibility+c.personality +
                            c.workload+c.difficulty)*5)

    if len(scores) == 0:
        scores.append(0)
    if len(scores) == 1:
        scores.append(scores[0])

    chart = Sparkline(scores, encoding='text')
    chart.color('0077CC')
    chart.size(450, 262)
    chart.marker('B', 'E6F2FA', 0, 0, 0)
    chart.line(1, 0, 0)
    chart.axes('y')

    if not settings.DEBUG:
        client = CamoClient(settings.CAMO_URL, key=settings.CAMO_KEY)
        url = client.image_url(chart.url)
    else:
        url = chart.url

    return url
Exemple #3
0
 def test_trailing_slash(self):
     client = CamoClient("https://fakecdn.org/", key="hello")
     self.assertEqual(
         client.image_url("http://example.net/images/hahafunny.jpg"),
         'https://fakecdn.org/735030fa488e1866b4302ac611c075d541a773e3/6874'
         '74703a2f2f6578616d706c652e6e65742f696d616765732f6861686166756e6e7'
         '92e6a7067',
     )
Exemple #4
0
 def test_trailing_slash(self):
     client = CamoClient("https://fakecdn.org/", key="hello")
     self.assertEqual(
         client.image_url("http://example.net/images/hahafunny.jpg"),
         'https://fakecdn.org/735030fa488e1866b4302ac611c075d541a773e3/687474703a2f2f6578616d706c652e6e65742f696d616765732f6861686166756e6e792e6a7067'
     )