Skip to content

Instantly share code, notes, and snippets.

View maiksprenger's full-sized avatar

Maik Sprenger maiksprenger

View GitHub Profile
@maiksprenger
maiksprenger / convert_models.py
Created July 15, 2014 13:12
Converts Oscar abstract models to new syntax
from shutil import move
from tempfile import mkstemp
import os
import re
def get_model_files():
root_path = os.path.dirname(os.path.realpath(__file__))
paths = []
for path, subfolders, all_files in os.walk(root_path):
def test_no_pending_changes(self):
output = cStringIO()
call_command('makemigrations', dry_run=True, stdout=output)
val = output.getvalue()
has_changes = 'No changes detected' not in output.getvalue()
if has_changes:
self.fail("Some apps need migrations: %s" % val)
<00 twttor 2006 slide>
This might not be a popular opinion, and this talk isn't about this, but I think Django's days of glory are over. I have no doubts that in the near future, we will not be building traditional websites, we will be building Javascript applications for the web. And that's a shame really. I really like Python and Django, and I don't like Javascript all that much. But maybe there's a Pythonic way forward!
<10 maik slide >
Hi, I'm Maik -- and this is "Building websites like it's 2006" 2006 was the year of the dog, so this talk is mostly pictures of dogs.
I've been involved with Django in one way or another for five years now. I'm an django-oscar core contributor; if you're looking for a Python ecommerce solution, look no more! And at the moment I'm helping Aymeric Augustin at Oscaro sell car parts. They're using Oscar, but that's a non-issue, so they gave me frontend work.
class Partner(models.Model):
"""
New partner class.
Note: 'name' and 'users' are dropped from Oscar's partner model.
"""
user = models.OneToOneField('auth.User')
def __unicode__(self):
return u'%s: %s' % (_('Fulfillment Partner'),
@maiksprenger
maiksprenger / pre-commit
Last active December 12, 2015 02:18 — forked from jonasvp/pre-commit
Removes copying to separate dir, and is a bit more explicit.
#!/bin/bash
# original jonasvp https://gist.github.com/858223
# also worth noting
# https://github.com/lbolla/dotfiles/blob/master/githooks/pre-commit
# http://python.dzone.com/articles/tips-using-git-pre-commit-hook
# stash unstaged changes, keeps our working dir clean
git stash -q --keep-index
# keeps our messages
(oscar)(master) T530i:django-oscar $ sites/sandbox/manage.py loaddata countries.json sites/_fixtures/p
ages.json sites/_fixtures/auth.json sites/_fixtures/ranges.json sites/_fixtures/offers.json
Problem installing fixture 'sites/_fixtures/offers.json': Traceback (most recent call last):
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/cor
e/management/commands/loaddata.py", line 196, in handle
obj.save(using=using)
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/cor
e/serializers/base.py", line 165, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/home/m/.virtualenvs/oscar/local/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/db/
#!/bin/sh
tmux start-server
tmux new-session -d -s trent -n serv
tmux new-window -t trent:1 -n solr
tmux new-window -t trent:2 -n DI
tmux new-window -t trent:3 -n DII
tmux new-window -t trent:4 -n oscar
tmux new-window -t trent:5 -n venv
from unittest import TestCase
from hypothesis import given
from hypothesis import strategies
class TestFoo(TestCase):
def setUp(self):
self.foo = 'meow'
from urllib.parse import urlencode
from hypothesis import strategies
HTTP_METHODS = ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT']
letters = strategies.characters(whitelist_categories=('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl'))
def http_method():
@maiksprenger
maiksprenger / shopware.py
Last active December 26, 2021 14:48
Basic Python 3 Shopware API client
"""
A basic Shopware 5 API client I threw together for a project. There's a few gotchas in here that
I thought are useful enough to others to publish it. But please take it as is - it works for my
purpose (processing Shopware articles daily), I make no claims beyond that.
"""
import logging
import os
import requests