keg-app-cookiecutter's People
keg-app-cookiecutter's Issues
Add default title block base-page.html
celery config needed for DevProfile, too
This CELERY config is needed up in the DevProfile.
Adjust flash alerts
- Make an alert demo view/page: https://github.com/level12/pai-tangerine/commit/28e58a23cd0e6cfef1817ff3e1f77cc4fb6a342a#diff-46deeff98d9e077a346ddde924a376f9R29
- Turn on dismissible alerts: https://github.com/level12/pai-tangerine/commit/28e58a23cd0e6cfef1817ff3e1f77cc4fb6a342a#diff-7f70f0b7852e2b6ee8b91c3ec2c081c4R12
- Adjust styles to make a bit slimmer: https://github.com/level12/pai-tangerine/commit/28e58a23cd0e6cfef1817ff3e1f77cc4fb6a342a#diff-b534082cb07dce2b668f3bb78be2b181
Update Sentry support to use environment variables
init extensions in .extensions
See RB for an example.
Add alembic migration for initial models
The cookiecutter includes three example models (Blog
, Comment
, and User
), but no matching alembic migration files.
A migration for the User
model, at least, would be a handy addition to the cookiecutter.
Add ping-db view
Or add it in Keg. Example:
https://github.com/level12/agari-adm/commit/203445a57e69a3c716327a794f885fe4fdaecee3
remove __future__
we need some stinking badges
Is our setup in celery.workers correct for avoiding double logging w/ uwsgi?
# Config specific to WSGI workers
uwsgi_config = {
# Don't log to stdout or uwsgi picks it up and that gets sent to syslog too resulting in double
# the log volume with no benefit.
'KEG_LOG_STREAM_ENABLED': False
}
It stops all output when running celery workers locally.
Support testing Alembic migrations
- https://github.com/level12/racebetter/blob/master/racebetter/libs/alembic.py
- https://github.com/level12/racebetter/blob/master/alembic/env.py#L11
- I think we could auto-detect the presence of the app and bootstrap if not present
- https://github.com/level12/racebetter/blob/master/racebetter/tests/migrate/test_event_ts_run_remodel.py
is the circleci/python:3.X image sufficient for our production apps?
I'm currently using the circleci/python:3.X images to run our tests. I did it because CircleCI caches Docker images per physical host and our Level 12 images aren't used much, so most of the time, our image has to be pulled. But, the CircleCi images are usually cached, so the tests run much faster.
But, we build our images with some libraries that our apps need, so this may not be sufficient. If it's not sufficient, then maybe we should build our python Docker images off of the CircleCi ones so that most of the layers that need to be pulled are cached.
Adjust app & cli init to permit top-level imports in CLI modules
See RaceBetter for an example.
Convert to Circle CI 2.0
Add grid support
Should probably put GridView and company in Keg Elements and then put example usage in this cookiecutter:
class GridView(AuthenticatedView):
grid_cls = None
template = 'grid-view.html'
title = None
def get(self):
return self.render_grid()
def render_grid(self):
if self.grid_cls is None:
raise NotImplementedError(
'You must set {}.grid_cls to render a grid'.format(self.__class__.__name__)
)
g = self.grid_cls()
g.apply_qs_args()
if hasattr(self, 'setup_grid'):
self.setup_grid(g)
if g.export_to == 'xls':
if g.xls is None:
raise DependencyError('The xlwt library has to be installed for Excel export.')
raise ImmediateResponse(g.xls.as_response())
template_args = {
'grid': g,
'title': self.title,
}
return flask.render_template(self.template, **template_args)
The example above is from RaceBetter.
revisit best way to manage celery from uwsgi
uwsgi docs give this example for Celery:
[uwsgi]
master = true
socket = :3031
smart-attach-daemon = /tmp/celery.pid celery -A tasks worker --pidfile=/tmp/celery.pid
See: http://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemons.html
Update Sentry integration to make username/email available in Sentry reports
Config Default vs DefaultProfile
the default class in config.py should be DefaultProfile
not Default
.
Add Keg-Login support
ATech integration of Keg-Login:
- Initial commit: https://github.com/level12/atech-imp/commit/cf890bbd1d485de41b2ba42acac5a977839ce3e7
- Fully support password reset https://github.com/level12/atech-imp/commit/7ea4a0c2f7c280be3cc414ffcde19bb0f7d6b993
- Allow admins to set user passwords directly and avoid email requirement: level12/atech-imp@a73bb797166b698ef10fd9125e8569ce50667e66
- Add base template for Keg-Login views: level12/atech-imp@d037ac94d85924b4ae6bbcbe1bdd74f70a6cd59b
- Fix login and lock page titles: level12/atech-imp@9fd8bde196d6537551246004eeacc21d529941ee
tox.ini is missing the call to count-heads.py
# Make sure alembic migrations only have one head.
python scripts/count-heads.py
Add basic navigation
Bump default Python version to 3.6
As soon as our wsgi servers can support 3.6 we should bump the default version used in the cookiecutter to 3.6.
pytest warning regarding TestApp
rapid/tests/test_views.py::TestApp
cannot collect test class 'TestApp' because it has a __init__ constructor
-- Docs: http://doc.pytest.org/en/latest/warnings.html
Consider setting CELERY config as individual variables
Due to the way Celery 4.0 handles configuration:
http://docs.celeryproject.org/en/latest/userguide/configuration.html#new-lowercase-settings
It seemed better to me to just have a single CELERY
variable in our app's config and pass whatever is in that when we setup the Celery app.
However, the disadvantage of that approach is that you can't easily inherit settings from configuration options lower in the stack. Right now, we have to have CELERY
defined in lots of places. If we moved to single config variables, then we could have defaults in DefaultProfile
and everything else would inherit and override what is needed.
refs #21
setup libs.mail
see keg_auth.mail
and agariadm.libs.mail
for example.
Create a user for the primary developer upon DB init
Could do this in Keg Auth, but since the app is likely to customize the user, maybe we should do it in the app instead?
Can tie into Keg's db_init_post
signal or, as long as DatabaseManager
is being customized in app.py
can just do:
def db_init(self):
super().db_init()
# If all the developer variables are set, then create our first user.
try:
ents.User.add(
name=self.app.config['DEVELOPER_NAME'],
email=self.app.config['DEVELOPER_EMAIL'],
password=self.app.config['DEVELOPER_PASSWORD'],
is_verified=True,
)
except KeyError:
pass
Look into CSRF errors when SERVER_NAME doesn't match host the app runs on
Is there a smarter way to set this up so that we aren't throwing hard to troubleshoot errors?
More details: https://level12.atlassian.net/wiki/spaces/devs/blog/2018/06/19/802684936/CSRF+protection+SERVER+NAME+variable
git pre-commit hook to validate circleci file
add service-restart.yaml playbook
Sentry support
Clarify views.auth is for KegAuth views
And add a views.private
for private/protected views for the app.
Email support
Nick's Keg-Mail integration in ATech: https://github.com/level12/atech-imp/commit/925226b1464c7ce0d9484d4d5001821ef61c9a6f
update readme notes regarding how to setup a monitor for Celery
Better yet, create a "SOP Readme" in Confluence and just link to it.
Ansible config is insufficient
See https://github.com/level12/agari-adm/pull/75 for everything I needed to do to get Agari provisioned & deployed to beta.
Add pytest assert rewrites for libs.testing
Example from Keg Auth's conftest.py file:
# Because our tests are in keg_auth.testing, which isn't a test module, pytest won't rewrite the
# assertions by default.
pytest.register_assert_rewrite('keg_auth.testing')
We have testing helper libraries, like the GridAssertions class that have asserts. When the asserts fail, we don't get helpful info from py.test unless we do a little custom config per the above.
Add Celery support
venv version check failure in circleci
command python -m venv --version
does not exist.
(submitting PR shortly)
Create Slack integration for this project
I have the sense of this repo also becoming a source of best practices. If that is the case, notifications to #dev may be helpful, just like we do for Ansible roles.
Fix danger alert CSS
Make adjustments needed for Keg test fixture changes
Keg work done here: level12/keg#93
But changes to tests were very verbose. I made an attempt on Agari: https://github.com/level12/agari-adm/commit/39e6dcdf801f7fe506d40e2f5dfe5b85880db229
I'm hoping pytest will make some improvements before we have to make this change: pytest-dev/pytest#517 (comment)
Use EntityBase from keg.elements instead of ModelBase
Per @guruofgentoo's suggestion, we should use EntityBase from keg.elements instead of ModelBase in tests like these:
Here is an example of it being used.
Rollback DB transaction after every test
# conftest.py
def pytest_runtest_setup():
# Avoid a messed up transaction interfering with other tests.
db.session.rollback()
Provide example code for purging Celery test queue before test runs
See Agari for example
Add authenticated test app to test_views.py
class ViewBase(object):
uses_auth = False
@classmethod
def testapp_login(cls, user=None):
if not user:
user = ents.User.testing_create()
ta = webtest.TestApp(flask.current_app)
resp = ta.get('/login')
resp.form['email'] = user.email
resp.form['password'] = user._plaintext_pass
resp = resp.form.submit()
assert ('success', 'Login successful.') in resp.flashes
return ta, user
@classmethod
def setup_class(cls):
# anonymous user
cls.ta = webtest.TestApp(flask.current_app)
if cls.uses_auth:
cls.authta, cls.auth_user = cls.testapp_login()
class TestPublic(ViewBase):
def test_home(self):
resp = self.ta.get('/')
assert resp.status_code == 302
assert '/login' in resp.headers['Location']
@mock.patch('tang.views.public.log', autospec=True, spec_set=True)
def test_ping_db(self, m_log):
resp = self.ta.get('/ping-db')
assert 'tang ok' in resp.text
m_log.info.assert_called_once_with('ping-db ok')
class TestPrivateViews(ViewBase):
uses_auth = True
def test_something(self):
pass
Add scafolding for migration tests
Remove pipenv pin to 11.10.0
I had to pin the install of pipenv to 11.10.0 to work around this issue:
Move libs.testing.ModelBase into a library
It should probably go into KegElements?
What can we learn from Django Cookiecutter
move extensions to .extensions
It's problematic to have the extensions initialized in .app
as views can't then import from .app
to get things like csrf
.
See RB app for an example.
remove sudo from circleci config.yml
@guruofgentoo updated the Docker image and sudo is no longer available
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.