Skip to content

Instantly share code, notes, and snippets.

@ruchej
ruchej / index.html
Last active May 13, 2017 13:05
Test maket
<!DOCTYPE html>
<html lang="ru">
<head>
<link rel="stylesheet" href="main.css" />
<link rel="icon" type="image/x-icon" href="icon/favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<meta charset="utf-8">
<title>Мебель класс 31</title>
</head>
<body>
@ruchej
ruchej / photolog_utils.py
Created March 4, 2019 13:41
Обработка изображений
from django.conf import settings
from PIL import Image, ImageEnhance
import os
import pdb
def get_box_thumb(image, TIS):
"""
image - объект картинка, на которую накладываете изображение
TIS - THUMB_IMAGE_SIZE (50, 50)
@ruchej
ruchej / omoton.models
Created December 12, 2019 05:46
Модель главного приложения
# -*- coding: utf-8 -*-
from django.utils.html import format_html
from django.db import models
STATUS_CHOICES = (
('draft', 'Черновик'),
('published', 'Опубликовано'),
)
@ruchej
ruchej / group_by_key
Last active February 19, 2020 11:22
Группировка именнованного кортежа по ключу
# -*- coding: utf-8 -*-
from collections import OrderedDict, namedtuple
from pprint import pprint
def group_by_key(iterable, key, sum_field):
"""Группирует список по полю key и суммирует по полю sum_field
iterable - список именованных кортежей
key - строка, название общего поля для группировки
table = [(593, 586, 487, '800400'), (594, 593, 487, '800800'), (595, 594, 487, '060000'), (596, 593, 487, '800800'), (592, 591, 487, '060000'), (578, 575, 487, '800800'), (581, 580, 487, '800800'), (570, 488, 487, '010100'), (627, 487, 487, '040000'), (571, 570, 487, '050000'), (572, 570, 487, '050000'), (573, 570, 487, '050000'), (574, 570, 487, '050000'), (575, 570, 487, '800400'), (576, 575, 487, '800800'), (580, 570, 487, '800400'), (579, 578, 487, '060000'), (591, 588, 487, '800800'), (582, 581, 487, '060000'), (583, 580, 487, '800800'), (584, 583, 487, '060000'), (585, 487, 487, '110101'), (586, 585, 487, '010100'), (587, 586, 487, '050000'), (588, 586, 487, '800400'), (589, 588, 487, '800800'), (590, 589, 487, '060000'), (577, 576, 487, '060000'), (569, 565, 487, '050000'), (617, 615, 487, '050000'), (618, 615, 487, '050000'), (619, 487, 487, '040000'), (620, 487, 487, '040000'), (621, 620, 487, '800500'), (622, 621, 487, '800800'), (625, 624, 487, '060000'), (624, 621, 487, '800800'), (614, 611, 487,
@ruchej
ruchej / .vimrc
Last active June 10, 2021 15:56 — forked from alexey-goloburdin/.vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
from django.conf import settings
from django.db import migrations, transaction
def forwards_func(apps, schema_editor):
if settings.DEBUG:
# Only in DEBUG mode!
try:
Account = apps.get_model("accounts", "Account")
UserStatus = apps.get_model("accounts", "UserStatus")
from django.conf import settings
from django.db import migrations, transaction
def forwards_func(apps, schema_editor):
Menu = apps.get_model("core", "Menu")
db_alias = schema_editor.connection.alias
with transaction.atomic():
Menu.objects.using(db_alias).bulk_create(
[
@ruchej
ruchej / Menu model
Last active February 3, 2022 17:01
class MenuManager(models.QuerySet):
"""docstring for MenuManager"""
def get_menu(self, attr):
return self.filter(title=attr, parent_id__isnull=True).first()
def get_submenu(self, user):
submenu = self.filter(Q(seen_seeker=True))
def get_supermenu(self, request):
from django.contrib.auth.models import AbstractUser, UserManager
from django.db import models
from django.utils.translation import gettext_lazy as _
class UserStatus(models.IntegerChoices):
MODERATOR = 0, _("Модератор")
JOBSEEKER = 1, _("Соискатель")
EMPLOYER = 2, _("Работодатель")