Exemplo n.º 1
0
    def allow( self, group_pk, member_pk ):

        response = HttpResponse( status=200 )

        try: # to find the objects
            self.group = Group.objects.get( pk=group_pk )

            if member_pk == "":
                # assumes that the user is the login record
                self.member = UserManager.getPerson(
                    self.request.user.username
                )
            else:
                self.member = self.group.persons.get( pk=member_pk )


            if self.request.method == "GET":
                response = self.get()
            elif self.request.method == "DELETE":
                response = self.delete()
            elif self.request.method == "PUT":
                response = self.put()
            elif self.request.method == "POST":
                response = self.post()

        except Group.DoesNotExist, ValueError:
            return HttpResponse( status=404 )
Exemplo n.º 2
0
    def post( self, group_instance ):

        user = self.request.user
        person = UserManager.getPerson( user.username )

        if self.request.POST.get( "needs_assistance" ):
            if group_instance.persons.filter(pk=person.pk):
                if group_instance.needs_assistance:
                    group_instance.needs_assistance = False
                else:
                    group_instance.needs_assistance = True

                group_instance.save()
                return HttpResponse( status=200 )
            return HttpResponse( status=404 )
        else:
            return HttpResponse( status=405 )
Exemplo n.º 3
0
    def post(self, group_instance):

        user = self.request.user
        person = UserManager.getPerson(user.username)

        if self.request.POST.get("needs_assistance"):
            if group_instance.persons.filter(pk=person.pk):
                if group_instance.needs_assistance:
                    group_instance.needs_assistance = False
                else:
                    group_instance.needs_assistance = True

                group_instance.save()
                return HttpResponse(status=200)
            return HttpResponse(status=404)
        else:
            return HttpResponse(status=405)
Exemplo n.º 4
0
    def allow(self, group_pk, member_pk):

        response = HttpResponse(status=200)

        try:  # to find the objects
            self.group = Group.objects.get(pk=group_pk)

            if member_pk == "":
                # assumes that the user is the login record
                self.member = UserManager.getPerson(self.request.user.username)
            else:
                self.member = self.group.persons.get(pk=member_pk)

            if self.request.method == "GET":
                response = self.get()
            elif self.request.method == "DELETE":
                response = self.delete()
            elif self.request.method == "PUT":
                response = self.put()
            elif self.request.method == "POST":
                response = self.post()

        except Group.DoesNotExist, ValueError:
            return HttpResponse(status=404)
Exemplo n.º 5
0
    Person.objects.exclude(user__username="******").delete()
    User.objects.exclude(username="******").delete()
    Tag.objects.all().delete()

    # set site

    try:
        number_of_persons = int(sys.argv[1])
        number_of_tags = int(sys.argv[2])
        tag_quantity = (int(raw_input("min: ")), int(raw_input("max: ")))
    except IndexError:
        number_of_persons = 100
        number_of_tags = 2
        tag_quantity = (1, 2)

    UserManager.addPerson("ilyakh").set_password("123")
    UserManager.addPerson("kritisk").set_password("123")
    UserManager.addPerson("michael").set_password("123")
    UserManager.addPerson("peder").set_password("123")
    UserManager.addPerson("rantonse").set_password("123")
    UserManager.addPerson("rantonse1").set_password("123")
    UserManager.addPerson("rantonse2").set_password("123")
    UserManager.addPerson("rantonse3").set_password("123")

    persons = (StudentGenerator(5)).generate(number_of_persons)
    tags = (TagGenerator()).generate(number_of_tags)

    print "Creating wishes for {0} persons, with a set of {1} tags".format(
        len(persons), len(tags))

    for p in persons:
Exemplo n.º 6
0
    User.objects.exclude( username="******" ).delete()
    Tag.objects.all().delete()

    # set site

    try:
        number_of_persons = int(sys.argv[1])
        number_of_tags = int(sys.argv[2])
        tag_quantity = ( int(raw_input( "min: " )), int(raw_input( "max: " )) )
    except IndexError:
        number_of_persons = 100
        number_of_tags = 2
        tag_quantity = (1, 2)


    UserManager.addPerson( "ilyakh" ).set_password( "123" )
    UserManager.addPerson( "kritisk" ).set_password( "123" )
    UserManager.addPerson( "michael" ).set_password( "123" )
    UserManager.addPerson( "peder" ).set_password( "123" )
    UserManager.addPerson( "rantonse" ).set_password( "123" )
    UserManager.addPerson( "rantonse1" ).set_password( "123" )
    UserManager.addPerson( "rantonse2" ).set_password( "123" )
    UserManager.addPerson( "rantonse3" ).set_password( "123" )

    persons = ( StudentGenerator( 5 ) ).generate( number_of_persons )
    tags = ( TagGenerator() ).generate( number_of_tags )

    print "Creating wishes for {0} persons, with a set of {1} tags".format(
        len(persons), len(tags) )

    for p in persons: