Skip to content

Instantly share code, notes, and snippets.

@ruchej
ruchej / tmp2.yml
Last active October 21, 2022 19:41
jupyterhub:
image: jupyterhub/jupyterhub:2.1.1
container_name: ${CONTAINER_NAME_PREFIX}jupyterhub
volumes:
- ./jupyterhub/jupyterhub_config.py:/etc/jupyterhub/jupyterhub_config.py
- ./jupyterhub/data:/home
working_dir: /home/jupyter
user: root
environment:
SERVER_HOST: ${SERVER_HOST}
@ruchej
ruchej / tmp.py
Last active September 2, 2022 06:18
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('advice_reactions', 'advice_id', new_column_name='advice_reсomendation_id')
op.drop_constraint('advice_reactions_advice_id_fkey', 'advice_reactions', type_='foreignkey')
op.create_foreign_key(None, 'advice_reactions', 'advices', ['advice_reсomendation_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
class A4ordConfirmForm(CrispyForm):
code = forms.IntegerField(label=l_(u'Код'), required=True)
next_stage = None
form = forms.CharField()
def __init__(self, *args, **kwargs):
super(A4ordConfirmForm, self).__init__(*args, **kwargs)
self.session = get_current_session()
def get_layout(self, *args, **kwargs):
class A4ordLoginView(TemplateView, BaseFormView):
template_name = 'accounts/a4ord_login.html'
success_url = '/'
forms = {'A4ordLoginForm': A4ordLoginForm, 'A4ordPasswordForm': A4ordPasswordForm}
form_class = A4ordLoginForm
prev_form_class = form_class
form = None
def post(self, request, **kwargs):
self.form_class = self.forms[self.request.POST['form']]
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, _("Работодатель")
@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.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(
[
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")
@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')
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,