Comments (4)
Work-around below allows a developer using one DJANGO_SETTINGS_MODULE, or QA using a "preview" button, to see what the page will look like when generated "for the public". This is made a bit orthogonal to django-bakery, but remains a work-around.
class IsPublicMixin:
def create_request(self, path):
request = RequestFactory().get(path)
request.GET = QueryDict('public=%s' % str(settings.IS_PUBLIC))
return request
def is_public(self):
public = self.request.GET.get('public', 'false').lower()
if public not in {'1', '0', 'yes', 'no', 'false', 'true'}:
logger.warning('public CGI parameter is not truthy')
return settings.IS_PUBLIC or public in {'1', 'yes', 'true'}
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'public': self.is_public()
})
return context
from django-bakery.
So, my plan is to shadow the "build" management command with one of my own which overrides the setings.IS_PUBLIC. I think a context manager that returns whether you are in a static context would also be a good idea here.
from django-bakery.
I don't need to do that - I've overridden create_request already... I guess its been awhile since I looked at this issue. I've been waiting for operations to make a mount point on the batch server so I can add this to my scheduled tasks.
from django-bakery.
So, to generalize this, we need to send custom meta-data to the request by default, by sending a custom header X-Bakery: 1 here https://github.com/datadesk/django-bakery/blob/2c9c495e4e8faca7b81fa57635d1631933f14171/bakery/views/base.py#L44
from django-bakery.
Related Issues (20)
- Relative path to the build directory is treated like absolute HOT 5
- BuildableModel doesn't work HOT 1
- Allow rendering function views HOT 1
- Bakery doesn't run `MIDDLEWARE_CLASSES`/`MIDDLEWARES` on build HOT 3
- InvalidCharsInPath error for BUILD_DIR while attempting to build project HOT 15
- Build fails when I add messages HOT 2
- Incremental builds through change detection? HOT 1
- Excluding model media from build HOT 1
- Gzip corrupts buildserver response
- Working with Digital Ocean Spaces
- Integration with django-storages (AWS S3)
- page parameters
- Scaling memory consumption?
- Fix build command on Windows HOT 6
- Add Django 4.0 support
- Broken link HOT 1
- BUILD_DIR fails if it you give it a `pathlib.Path`
- Add an option to run AutoPublishingBuildableModel tasks without celery
- Integrate publish command with django-storages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-bakery.