Example #1
0
    def get(self, request, *args, **kwds):
        user_input = request.GET.get('uname', 'pablo')
        query = "SELECT * FROM auth_user WHERE username = '******'" % user_input

        db_error, users = get_users(query)
        db_error, users = fake_error_handling(db_error, users)

        context = self.get_context_data(db_error=db_error,
                                        users=users,
                                        success=True)

        return render(request, self.template_name, context)
Example #2
0
    def get(self, request, *args, **kwargs):
        if 'q' not in request.GET:
            return render(request, self.template_name, self.get_context_data())

        # The user filled the form, lets use it!
        # pylint: disable=E1101
        user_input = request.GET['q']
        query = "SELECT * FROM auth_user WHERE id = %s" % user_input

        db_error, users = get_users(query)
        db_error, users = fake_error_handling(db_error, users)

        context = self.get_context_data(db_error=db_error,
                                        users=users,
                                        success=True)

        return render(request, self.template_name, context)
Example #3
0
    def post(self, request, *args, **kwds):
        # pylint: disable=E1101
        form = GenericForm(data=request.POST)
        if not form.is_valid():
            context = self.get_context_data(success=False,
                                            form=GenericForm())
        else:
            user_input = form.cleaned_data[GenericForm.INPUT]
            query = "SELECT * FROM auth_user WHERE id = %s" % user_input

            db_error, users = get_users(query)
            db_error, users = fake_error_handling(db_error, users)

            context = self.get_context_data(db_error=db_error,
                                            users=users,
                                            success=True,
                                            form=GenericForm())

        return render(request, self.template_name, context)