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 OrganizationImportExportResource(ModelResource): | |
types = widgets.ManyToManyWidget(model=graph_models.OrganizationType, | |
field='name') | |
class Meta: | |
model = Organization | |
fields = [ | |
'name', | |
] | |
import_id_fields = ['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
import hashlib | |
import time | |
import requests | |
class ReadableAPIClient: | |
""" | |
API Client for Readable.io, written for Python 3 | |
See API documentation: https://readable.io/api/docs/ |
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
from django import forms | |
from django.contrib import admin | |
from django.utils.translation import ugettext as _ | |
from django.contrib.auth.admin import UserAdmin | |
from django.contrib.auth.forms import ReadOnlyPasswordHashField | |
from .models import User | |
class UserCreationForm(forms.ModelForm): |
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 csv | |
from sys import argv | |
import requests | |
def transform_user_file(filename: str) -> []: | |
user_file = open(filename, 'r') | |
user_data = csv.reader(user_file) | |
# skip first row |
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 React, { Component } from "react"; | |
import PropTypes from "prop-types"; | |
import Helmet from "react-helmet"; | |
class PreviewPage extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
post: { | |
title: { |
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
from model_mommy import generators | |
MOMMY_CUSTOM_FIELDS_GEN = { | |
'easy_thumbnails.fields.ThumbnailerImageField': generators.gen_image_field, | |
'model_utils.fields.AutoCreatedField': generators.gen_datetime, | |
'model_utils.fields.AutoLastModifiedField': generators.gen_datetime, | |
'django_extensions.db.fields.AutoSlugField': generators.gen_slug, | |
} |
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
# Inspiration from https://djangosnippets.org/snippets/116/ | |
from django import template | |
import datetime | |
register = template.Library() | |
def days_until(value): | |
""" |
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
from django.db import models | |
from django.utils.translation import ugettext_lazy as _ | |
from model_utils.fields import AutoCreatedField, AutoLastModifiedField | |
class IndexedTimeStampedModel(models.Model): | |
created = AutoCreatedField(_('created'), db_index=True) | |
modified = AutoLastModifiedField(_('modified'), db_index=True) | |
class Meta: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 StudenAdmin(admin.ModelAdmin): | |
inlines = (StudentRecordInline,) |
NewerOlder