This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Copyright 2021 Mygod | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.handlers.wsgi import WSGIRequest | |
from io import StringIO | |
from django.http import QueryDict | |
def fake_request(method=None, fake_user=False): | |
'''Returns a fake `WSGIRequest` object that can be passed to viewss. | |
If `fake_user` is `True`, we attach a random staff member to the request. | |
Even if not set, you can still do this manually by setting the `user` | |
attribute on the returned object. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JsonType implements UserType<Object>, DynamicParameterizedType { | |
private final MutabilityPlan<Object> mutabilityPlan; | |
private final ObjectMapper objectMapper = new ObjectMapper(); | |
private Type propertyType; | |
private Class<?> propertyClass; | |
public JsonType() { | |
this.mutabilityPlan = new MutableMutabilityPlan<>() { | |
@Override |