Skip to content

Instantly share code, notes, and snippets.

View dima-kov's full-sized avatar

Dmytro Kovalchuk dima-kov

  • Kyiv, Ukraine
View GitHub Profile
def add_serie(request):
context = {
'serie_form': AddSerieForm()
}
if request.POST and request.user.is_authenticated():
add_serie_form = AddSerieForm(request.POST)
if add_serie_form.is_valid():
serie = add_serie_form.save(commit=False)
def add_serie(request):
context = {
'serie_form': AddSerieForm()
}
if request.POST and request.user.is_authenticated():
add_serie_form = AddSerieForm(request.POST)
if add_serie_form.is_valid():
def add_serie(request):
context = {
'serie_form': AddSerieForm()
}
if request.POST and request.user.is_authenticated():
add_serie_form = AddSerieForm(request.POST)
if add_serie_form.is_valid():
serie = add_serie_form.save(commit=False)
#settings.py
BADGIFY_BADGE_MODEL = 'main.models.GuidaBadge'
#main.models
from badgify.models.base.badge import Badge as BaseBadge
class GuidaBadge(BaseBadge):
model_name = models.CharField(max_length=40)
required_number = models.IntegerField()
@dima-kov
dima-kov / pipeline.py
Created July 19, 2017 17:56
Django Social Login Avatar Pipeline
from django.core.files.base import ContentFile
from urllib.request import urlopen
def avatar(backend, strategy, details, response, user=None, *args, **kwargs):
url = None
if backend.name == 'facebook':
url = "http://graph.facebook.com/{}/picture?type=large".format(
response['id'])
filename = 'fb_avatar_{}.jpg'.format(user.username)
@dima-kov
dima-kov / views.py
Created July 27, 2017 16:33
Return view from another one and change method
def form_invalid(self, form):
print(form.errors)
print(self.request)
# print(help(self.request))
request = self.request
request.method = 'GET'
return BookView.as_view(booking_form=form)(request=request, pk=1)
{
"particles": {
"number": {
"value": 150,
"density": {
"enable": false,
"value_area": 1603.4120608655228
}
},
"color": {
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUfxiteH7DOGS4Js3bNdqc/WlEGfzgdITxdpxFNo4rzyV8BwBV4gQKiTGbzyD82uv9o7diFpxbV2YG8OlXZ2It10jgOZ3B+Kp8xSs2ONM3h53k0QzZ3LfyAEGHE0Zb6YI/JW/q+M4CChHBlnWws4K6uoZRnWBh36C+6XFr65QRvIaE2TZ9GE1rjU583J4aFP4GSJk9vFMKGFG3ROXZml/ow9HUZYgPuzpF6IFPtTeW0qUBL0qnQMeRnPhg8U5BOuaBcc7QaXMUYoZM7KwZKXL+f+8911QYq6xgKNMvx6MFer3IdFUKFo1B2xze5rZvvMSvUxhIj/NyouvXnw/XwNe7 kovalchuk@4YMXRZ1
server {
charset utf-8;
listen 8000;
server_name 188.166.100.169;
client_max_body_size 10m;
access_log /var/sites/blog/log/nginx.access.log;
error_log /var/sites/blog/log/nginx.error.log;
import { Component, OnInit } from '@angular/core';
import { FlashMessagesService } from 'angular2-flash-messages';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { AfterViewInit, ElementRef, Renderer } from '@angular/core';
import { FormGroup, FormBuilder, Validators, FormsModule } from '@angular/forms';
import { Recipe } from '../../models/recipe';
import { Diary } from '../../models/diary';
import { GetRecipesService } from '../../services/get-recipes.service';
import { MorgningRecipes } from './../../models/morning-recipes';