Skip to content

Instantly share code, notes, and snippets.

View volgoweb's full-sized avatar

Dima Koldunov Python Developer volgoweb

  • Российская Федерация
View GitHub Profile
@volgoweb
volgoweb / celery_1.py
Created February 11, 2020 08:26
Find a mistake in celery task
#################
# Find a mistake:
#################
from django.core.cache import cache
from celery import shared_task
@shared_task()
def clear_blog_item_cache(article):
@volgoweb
volgoweb / models.py
Created February 11, 2020 08:29
refactor unpublishing the posts
# .. 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()
######################################################
# 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()
@volgoweb
volgoweb / money_transfer.py
Created August 19, 2021 14:23
19_08_2021 Interview (Shared)
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):
@volgoweb
volgoweb / conftest.py
Created February 2, 2022 07:53 — forked from shaypal5/conftest.py
Temp environment variables for pytest
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 = []