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
import os | |
import pytest | |
try: | |
from.temp_env_var import TEMP_ENV_VARS, ENV_VARS_TO_SUSPEND | |
except ImportError: | |
TEMP_ENV_VARS = {} | |
ENV_VARS_TO_SUSPEND = [] | |
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
import uuid | |
from decimal import Decimal | |
from django.db import transaction | |
# send a request to PayPal.com to transfer money | |
from .services import transfer_money_via_paypal | |
class BillingAccount(models.Model): |
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
###################################################### | |
# To Do: How can we refactor code to make that faster? | |
###################################################### | |
def func(user, moderator_ids): | |
for post in Post.objects.all().order('?'): | |
if user.pk in moderator_ids: | |
post.updated_at = timezone.now() | |
post.save() |
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
# .. import section .. | |
class Post(models.Model): | |
author = models.ForeignKey(CustomUserModel) | |
title = models.CharField(max_length=200) | |
text = models.CharField(max_length=15000) | |
is_published = models.BooleanField() |
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
################# | |
# Find a mistake: | |
################# | |
from django.core.cache import cache | |
from celery import shared_task | |
@shared_task() | |
def clear_blog_item_cache(article): |
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
# | |
# File templatetags/custom_pagination.py | |
# | |
from django import template | |
register = template.Library() | |
@register.simple_tag |
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
# Generated by Django 2.2 on 2019-06-06 14:38 | |
""" | |
If you add a migration that uses content types and/or permissions you should apply the functions to fill particular tables in DB. | |
""" | |
from django.db import migrations | |
from django.contrib.contenttypes.management import create_contenttypes | |
from django.contrib.auth.management import create_permissions | |
from django.apps import apps as _apps |
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 BaseDataStructure(object): | |
"""The class is intended for definition contract objects which might be used as argument for various classes. | |
The example of using: | |
class SomeServiceInput(BaseDataStructure): | |
__accessible__ = { | |
'email': str, | |
'template_type': int, | |
} | |
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 collections import OrderedDict | |
members = [ | |
#{'name': 'member', 'skills': set('skill1', 'skill2', ...)} | |
{'name': 'Jan', 'skills': set(('PHP', 'HTML'))}, | |
{'name': 'Bep', 'skills': set(('HTML', 'CSS'))}, | |
{'name': 'Leo', 'skills': set(('CSS', 'PHP'))} | |
] | |
project = OrderedDict([ | |
#'task': ['skill', nrhourswork] | |
('A', ['PHP', 2]), |
NewerOlder