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
| /* | |
| Can be used to implement star ratings. | |
| HTML: | |
| <div data-rating data-value="0..5"></div> | |
| emits 'ratingChanged' if a star was clicked | |
| updates stars if 'changeComplete' event is received. | |
| CSS: |
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.shortcuts import render_to_response | |
| from social.backends.oauth import BaseOAuth2 | |
| from social.pipeline.partial import partial | |
| @partial | |
| def pick_character_name(backend, details, response, is_new=False, *args, **kwargs): | |
| if backend.name == 'battlenet-oauth2' and is_new: | |
| data = backend.strategy.request_data() | |
| if data.get('character_name') is None: |
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
| ko.bindingHandlers.slideToggleVisible = { | |
| init: function(element, valueAccessor) { | |
| var value = valueAccessor(); | |
| ko.unwrap(value) ? $(element).show() : $(element).hide(); | |
| }, | |
| update: function(element, valueAccessor) { | |
| var value = valueAccessor(); | |
| ko.unwrap(value) ? $(element).slideDown() : $(element).slideUp(); | |
| } | |
| }; |
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
| class ForeignCountMeta(ModelBase): | |
| """ | |
| Metaclass that adds couter methods for reverse foreign keys of Django models. | |
| The methods that will be creates are defined in the models Meta options: | |
| class CountedParent(models.Model, metaclass=ForeignCounterMeta): | |
| class Meta: | |
| counted_fields = { | |
| "child1_count": {'relation_name': 'child1', 'short_description': 'Child 1 count'}, |
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
| # custom response handler for flask and chromelogger | |
| # use chromelogger to log directly to the chorme development console | |
| # (see: https://github.com/ccampbell/chromelogger-python) | |
| # | |
| # put this in your application config | |
| if app.debug: | |
| import chromelogger as console | |
| @app.after_request | |
| def chromelogger(response): |
NewerOlder