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 -*- | |
"""Add permissions for proxy model. | |
This is needed because of the bug https://code.djangoproject.com/ticket/11154 | |
in Django (as of 1.6, it's not fixed). | |
When a permission is created for a proxy model, it actually creates if for it's | |
base model app_label (eg: for "article" instead of "about", for the About proxy | |
model). |
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 | |
""" | |
This script compiles and installs Python3 on your CentOS server. | |
Built based on the steps described by Digital Ocean (https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4) | |
""" | |
import os | |
import subprocess |
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
# Hacky script for downloading videos from PyVideo and converting them to m4v | |
# format so they can be synced onto your apple device. Useful if you | |
# want to see everything that happened at PyCon while commuting. | |
# This version supports the new PyVideo.org website | |
# | |
# Requirements: | |
# * pip install requests BeautifulSoup | |
# * youtube-dl (from https://github.com/rg3/youtube-dl/) - you can execute | |
# pip install youtube-dl to install it | |
# This was the only YouTube downloader I found that worked. It doesn't |
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
""" | |
What you have to do to use this is extending BaseItem rather than extending DjangoItem because DjangoItem looks for _meta.fields and ignores _meta.many_to_many. | |
This will handle the ManyToMany fields in your model. So you have to scrape the data using DDS and return an Item that contains the ManyToMany field but as a list []. | |
The BaseItem class will basically call a function in your Item class named save_%s_values for each ManyToMany field. So if your ManyToMany field is called | |
photos, you'll have to have a method called save_photos_values which accepts the model, the model_field and the list of values. Example: | |
def save_photos_values(self, model, model_field, values): | |
for value in values: | |
image_filename = settings.IMAGES_STORE + value['path'] | |
image = create_and_save_image_from_file(model.title, image_filename) | |
model_field.add(image) |
NewerOlder