This file contains 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
# -*- coding: utf-8 -*- | |
class Profile(models.Model): | |
foo = models.CharField() | |
user = models.ForeignKey(User) | |
@property | |
def first_name(self): | |
return self.user.first_name |
This file contains 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
def formation(request): | |
if request.method == 'POST': | |
form = ConsultFormationForm(request.POST) | |
if form.is_valid(): | |
theme_choisi = form.cleaned_data['theme'] | |
duree_min_choisie = form.cleaned_data['duree_min'] | |
duree_max_choisie = form.cleaned_data['duree_max'] | |
if theme_choisi is not None: | |
if duree_min_choisie != 'no' and duree_max_choisie !='no': |
This file contains 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 ho.pisa as pisa | |
from django.template import loader | |
from django.http import HttpResponse | |
def render_to_pdf(*args, **kwargs): | |
response = HttpResponse('', mimetype='application/pdf') | |
response['Content-Disposition'] = 'attachment; filename=%s' % kwargs.pop('filename', 'something.pdf') | |
document = loader.render_to_string(*args, **kwargs) | |
print document |
This file contains 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
def workday?(date) | |
1 <= date.wday <= 5 | |
end | |
workday_count_between(start_date, end_date) | |
(start_date..end_date).count{ |d| workday?(d)} | |
end |
This file contains 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 Recette < AR::Base | |
include Feeds::ModelMixin | |
end | |
class Article < AR::Base | |
include Feeds::ModelMixin | |
end | |
module Feeds |
This file contains 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 FormDeclaration(models.Model): | |
form_fields = JSONField() | |
f = FormDeclaration() | |
f.form_fields = [ | |
{'name': 'foo', 'type': 'TextField'} | |
] |
This file contains 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
diff --git a/parltrack/current_meps_json_2_sql.py b/parltrack/current_meps_json_2_sql.py | |
index 1690f46..9053972 100644 | |
--- a/parltrack/current_meps_json_2_sql.py | |
+++ b/parltrack/current_meps_json_2_sql.py | |
@@ -174,8 +174,8 @@ def add_addrs(mep, addrs): | |
name=bxl["Address"]["Building"], | |
street=bxl["Address"]["Street"], | |
postcode=bxl["Address"]["Zip"]) | |
- mep.bxl_floor = bxl["Address"]["Office"][:3] | |
- mep.bxl_office_number = bxl["Address"]["Office"][3:] |
This file contains 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
#!/usr/bin/env python | |
import threading | |
import subprocess | |
results = [] | |
def launch_job(arg): | |
results.append(subprocess.Popen(['/bin/echo %s' % arg], shell=True, stdout=subprocess.PIPE).communicate()[0]) | |
This file contains 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
MEP.objects.filter(countrymep__end__gt=d, countrymep__begin__lt=d).extra(select={'current_country_id': 'meps_countrymep.country_id'}) |
This file contains 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
GET /votes/ACTA_resolution/693/abstention/ | |
avant: 272 -> 84ms | |
après 116 -> 69ms | |
\o/ |