Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ziafazal/wl-245: multiple backend support for microsite #11073

Merged
merged 1 commit into from
Jan 15, 2016

Conversation

ziafazal
Copy link
Contributor

@mattdrayer This is PR has some enhancements to microsite module. e.g allows multiple backend support for microsites configuration and templates. I have added some test coverage up 95%.

@ziafazal
Copy link
Contributor Author

jenkins run js

@ziafazal
Copy link
Contributor Author

jenkins run python

@mattdrayer
Copy link
Contributor

@chrisndodge @felipemontoya -- here is an updated PR for #10158 -- it's currently WIP, but feel free to take a look when you have a moment.

@ziafazal ziafazal changed the title WIP:Ziafazal/wl-245: multiple backend support for microsite Ziafazal/wl-245: multiple backend support for microsite Dec 30, 2015
@ziafazal
Copy link
Contributor Author

ziafazal commented Jan 1, 2016

@mattdrayer we finally have a green build now.

@mattdrayer
Copy link
Contributor

@chrisndodge @felipemontoya -- looking like we are in good shape now thanks to @ziafazal's hard work! If you can find some time in the next 24 hours to review this PR, I will also take a pass through and assuming everything looks good we can merge this week.

@felipemontoya
Copy link
Member

@mattdrayer, @chrisndodge, @ziafazal. It's nice to see this in a green build. I just got back to the office, but I will sure take a good look at this today and report my findings

@felipemontoya
Copy link
Member

@mattdrayer @ziafazal, I gave this a good look and it worked nicely. Great work @ziafazal.
I did however find a minor error when using the database TEMPLATES_BACKEND. When the request was not in a microsite the microsite_config_key was None and could not be concatenated. I fixed it by preventing the non-microsite requests to use the TEMPLATES_BACKEND altogether. I will make a PR against this branch shortly, since I can't push directly to it.

@mattdrayer
Copy link
Contributor

@felipemontoya now that we have merged your PR are you good with this changeset?

@felipemontoya
Copy link
Member

As far as I can tell we are ready with this

@mattdrayer
Copy link
Contributor

Okay, great, then I'm going to give it a 👍, and if @ziafazal can squash the commits maybe we can get @douglashall or @mjfrey to take a look at the code tomorrow.

@felipemontoya
Copy link
Member

As far as I can tell we are ready with this, and I'm very good with the changeset

@ziafazal
Copy link
Contributor Author

ziafazal commented Jan 7, 2016

@mattdrayer squashed commits.

@mjfrey
Copy link
Contributor

mjfrey commented Jan 7, 2016

@mattdrayer code looks good. I don't have all the context for this.

@mattdrayer
Copy link
Contributor

@mjfrey neither do I :) most of the context is still with @chrisndodge but we do have @felipemontoya as a resource and @ziafazal has gained knowledge through this PR as well. So we appreciate your review of the code even w/o all of the background.

"""
Overridden method which will allow us to look up templates from a database (optionally)
"""
from microsite_configuration.microsite import get_template as get_microsite_template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this import not in the file header and in a method?

@mjfrey
Copy link
Contributor

mjfrey commented Jan 7, 2016

would also be nice to document an example use of each backend. In a comment of each backend.

@felipemontoya
Copy link
Member

Thanks @mjfrey. @ziafazal how should we go about this? I can address the comments in a new PR against this branch, or if you want, you can make the changes directly.

Let me know, and I'll get to it tomorrow

@ziafazal
Copy link
Contributor Author

ziafazal commented Jan 8, 2016

Thanks @mjfrey. I have tried to answer questions and made changes as per your feedback.

@ziafazal
Copy link
Contributor Author

ziafazal commented Jan 8, 2016

jenkins run bokchoy

@ziafazal
Copy link
Contributor Author

jenkins run lettuce


# now test when we call in a value Microsite ORG, note this is defined in test.py configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to break this second check out into a separate test.

@mattdrayer
Copy link
Contributor

Okay @ziafazal I have completed my revisit -- hopefully I have not made too many requests! Mostly I think I am looking for some additional info/comments and some renames + light refactoring. However I did have one or two things that may require additional work -- please let me know what you think.

@ziafazal ziafazal force-pushed the ziafazal/WL-245 branch 3 times, most recently from cb6c628 to 8131a29 Compare January 13, 2016 15:18
@ziafazal
Copy link
Contributor Author

@mattdrayer I have made almost all of the changes you suggested including adding django sites framework support to Microsite model. I have rebased it with master and resolved conflicts.

@felipemontoya
Copy link
Member

Thanks @ziafazal, this was great work. I am downloading it to my devstack now

@mattdrayer
Copy link
Contributor

jenkins run python

@felipemontoya
Copy link
Member

@mattdrayer and @ziafazal , I tested this throught on my devstack and I found that during the rebase some of the modifications from #10623 were reverted. Specifically the statup.py part with the enable_microsites_pre_startup().

As long as we don't have a dynamic template finder for the django template, the enable_microsite routine, will have to be split into a pre django.setup() and a post django.setup(). I'll make a PR against this branch with said correction.

@ziafazal
Copy link
Contributor Author

jenkins run python

Adding the declaration of the settings object to openedx.conf to be able to import it from a nicer location

Resolving quality violations

Merging dicts with the settings definition when they exist in the microsite configuration

Using a cache to improve the perfomance of quering any dictionary in the microsite definition

Ignoring the invalid-name pylint warning since the names must be kept thsi way to stay the same as the ones in django.
Removing the default dict argument as per https://docs.python.org/2/tutorial/controlflow.html#default-argument-values

Extracting the implementation of the microsite to a selectable backend.

Leaving the function startup.enable_microsites for backwards compatibilityy

Adding a database backend

Using a cache to improve the perfomance of quering any dictionary in the microsite definition.
Changed the database backend so that it extends the settings file backend and removed all the unnecessary methods.

Using the backend provider for the get_dict function

some tweeks and some initial unit tests

Using getattr as a function insteal of calling the underlying __getattr__ directly

Adding an ModelAdmin object for the microsite model in the django-admin panel

refactor enable_microsites()

consolidate/refactor some shared code

add config to aws.py and add migration files

fix tests

Changes to get the backends to run after the refactor

add archiving capabilities to microsites. Also make a few notes about performance improvements to make

fix tests

Making the query to find if microsites exist in the database faster

add ORG to microsite mapping tables and some performance improvements

allow for Mako templates to be pulled from the database

fix tests

For the database template backend the uri of the template does not use the filesystem relative path

Fixing pylint violations

Added caching of the templates stored in the database

Fixing pylint errors

fix pylint

Clearing the cache on model save

Fixing pylint errors

rebased and added test coverage

rebased cdodge/microsite-improvements branch with master and added test
coverage

added missing migration

fix quality violations

add more test coverage

mattdrayer: Add microsite_configuration to cms.INSTALLED_APPS

added microsite settings to cms/envs/test.py

run session cookie tests only in LMS

fixed broken tests

putting middleware changes back

Preventing the template_backend to be called on requests which have no microsite

changes to address feedback from mjfrey

changed BaseMicrositeBackend to AbstractBaseMicrositeBackend

changes after feedback from mattdrayer

fixed broken tests and quality violations

Allowing the backend to handle the enable_pre_startup routine

Typos and docstrings

Adressing feedback

Fixing python tests

add comment to explain why we need enable_microsites_pre_startup()
@mattdrayer
Copy link
Contributor

Alright, this epic PR is looking good to me at this point -- @felipemontoya can you take one last look now that your changeset has been merged. FYI, the next RC will be cut today at 11am Eastern, so if we're good to go I will merge this morning.

@felipemontoya
Copy link
Member

@mattdrayer I downloaded it again, fired it on devstack on some test scenarios, and went through the code again. It looks good to me 👍

@mattdrayer
Copy link
Contributor

Fantastic -- okay everyone, we are SHIPPING this changeset -- nice work all!!! 👍 👍 👍

mattdrayer added a commit that referenced this pull request Jan 15, 2016
Ziafazal/wl-245: multiple backend support for microsite
@mattdrayer mattdrayer merged commit 9bcb116 into master Jan 15, 2016
@benpatterson benpatterson deleted the ziafazal/WL-245 branch August 2, 2016 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants