copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from recipebook.maricilib.warnings import module_deprecated module_deprecated(__name__, "recipebook.maricilib.django.db.models.managers") from datetime import date, datetime from dateutil.relativedelta import relativedelta from django.db import models class DailyScoreManager(models.Manager): """ DailyScoreクラス継承テーブルに対する操作の実装クラス。 """ qlimit_min = 100 def get_score_object(self, object, score): try: score_obj = self.get(object=object, scored_at=date.today()) except self.model.DoesNotExist, e:
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from recipebook.maricilib.warnings import module_deprecated module_deprecated(__name__, "recipebook.maricilib.django.core.paginator") from django.core.paginator import Paginator as BasePaginator from django.core.paginator import Page as BasePage class Paginator(BasePaginator): """ django.core.paginator.Paginatorクラスの拡張。 このクラスのインスタンスがpageメソッドで返すPageインスタンスは、 around_page_rangeプロパティを持つ。 """ def page(self, number): page = super(Paginator, self).page(number) page.__class__ = Page return page
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ from recipebook.maricilib.warnings import module_deprecated module_deprecated(__name__, "recipebook.maricilib.django.decorators") from django.http import HttpResponseNotAllowed from recipebook.maricilib.multimethod import multifunc, ByContentMultiMethod class ByDjangoHTTP(ByContentMultiMethod): POST = "POST" GET = "GET" def get_key(self, request, *args, **kwargs): return (request.method.upper(),) def notfound(self): return lambda *args, **kwargs: HttpResponseNotAllowed([]) def __getattribute__(self, name):
# coding: utf-8 from recipebook.maricilib.warnings import module_deprecated module_deprecated(__name__, "recipebook.maricilib.django.shortcuts") from django.template import loader from django.db.models.manager import Manager from django.db.models.query import QuerySet def render_to_response_of_class(response_cls, *args, **kwargs): httpresponse_kwargs = {"mimetype": kwargs.pop("mimetype", None)} return response_cls(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) def _get_queryset(klass): if isinstance(klass, QuerySet): return klass elif isinstance(klass, Manager): manager = klass else: manager = klass._default_manager return manager.all() def get_object(klass, *args, **kwargs): queryset = _get_queryset(klass) try: return queryset.get(*args, **kwargs) except queryset.model.DoesNotExist: return None