Ejemplo n.º 1
0
def load_data():
    url = 'http://nwpei.prz.rzeszow.pl/~szczep/Lato2015_timetable.csv'
    resource = urllib.request.urlopen(url)
    reader = csv.reader(resource.read().decode('utf-8').splitlines())
    Sup = Database()

    for i in reader:
        group = i[3]
        key = i[0]
        Sup.add(group, i, key)

    Sup.remove_useless()

    for group in Sup.plan.keys():
        for i in Sup.plan[group].keys():
            s = Sup.cleanDuplicates(Sup.plan[group][i])
            del Sup.plan[group][i]
            Sup.add_single(group, s, s[0])

    K = Sup.plan
    for i in K:
        for j in K[i]:
            s = K[i][j]
            A = Activity(code=int(s[0]), Hour=s[2], Day=s[1],
                         Subject=s[4], Teachers=s[5], Students=s[3], Tag=s[6], Room=s[7], Comment=s[8])
            A.save()
Ejemplo n.º 2
0
 def create(self, request, lang, id, limit=None):
     check_authentication(request)
     try:
         frame = Frame.objects.get(id=id, language__id=lang)
     except Frame.DoesNotExist:
         return rc.NOT_FOUND
     
     user = request.user
     activity = Activity.get(request.POST.get('activity', 'Web API'))
     text1 = request.POST['text1']
     text2 = request.POST['text2']
     vote = int(request.POST.get('vote', 1))
     raw = RawAssertion.make(user, frame, text1, text2, activity, vote)
     return raw
Ejemplo n.º 3
0
    def create(self, request, lang, id, limit=None):
        check_authentication(request)
        try:
            frame = Frame.objects.get(id=id, language__id=lang)
        except Frame.DoesNotExist:
            return rc.NOT_FOUND

        user = request.user
        activity = Activity.get(request.POST.get('activity', 'Web API'))
        text1 = request.POST['text1']
        text2 = request.POST['text2']
        vote = int(request.POST.get('vote', 1))
        raw = RawAssertion.make(user, frame, text1, text2, activity, vote)
        return raw
Ejemplo n.º 4
0
 def create(self, request, type, lang, id):
     check_authentication(request)
     try:
         theclass = RatedObjectHandler.classes[type]
     except KeyError:
         return rc.NOT_FOUND
     try:
         theobj = theclass.objects.get(id=id, language__id=lang)
         user = request.user
         val = int(request.POST['value'])
         activity = Activity.get(request.POST.get('activity', 'Web API'))
         theobj.set_rating(user, val, activity)
         return {
             'type': type,
             type: theobj,
             'votes': theobj.votes.all(),
         }
     except theclass.DoesNotExist:
         return rc.NOT_FOUND
     except (KeyError, ValueError):
         return rc.BAD_REQUEST
Ejemplo n.º 5
0
 def create(self, request, type, lang, id):
     check_authentication(request)
     try:
         theclass = RatedObjectHandler.classes[type]
     except KeyError:
         return rc.NOT_FOUND
     try:
         theobj = theclass.objects.get(
             id=id, language__id=lang
         )
         user = request.user
         val = int(request.POST['value'])
         activity = Activity.get(request.POST.get('activity', 'Web API'))
         theobj.set_rating(user, val, activity)
         return {'type': type,
                 type: theobj,
                 'votes': theobj.votes.all(),
                 }
     except theclass.DoesNotExist:
         return rc.NOT_FOUND
     except (KeyError, ValueError):
         return rc.BAD_REQUEST