- Make sure the image file you'd like to use is shared publicly.
This file contains hidden or 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,) |
This file contains hidden or 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 hidden or 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
| " Initialize pathogen for flake8 | |
| execute pathogen#infect() | |
| syntax on | |
| filetype plugin indent on | |
| " remove trailing spaces in Python & Markdown | |
| autocmd BufWritePre *.py :%s/\s\+$//e | |
| autocmd BufWritePre *.md :%s/\s\+$//e | |
| " call flake8 at every save |
This file contains hidden or 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 hidden or 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
| #!/bin/bash | |
| # installs virtualenvwrapper and adds initialization logic for .bashrc file | |
| # change RC_FILE value as needed | |
| RC_FILE=~/.bashrc | |
| # global install of virtualenvwrapper | |
| sudo pip install virtualenvwrapper | |
| # creation of directory to store Python virtual environments |
This file contains hidden or 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 -*- | |
| """ | |
| Calculates the following 'Developer Focus' metric using | |
| data from the Pivotal Tracker API: | |
| # unique developers actively working on active projects / | |
| Open stories ("started" state) from active projects | |
| For this first pass, the IDs of active projects and | |
| developers are set as environment variables. | |
| In the future, it may be possible to determine these |
This file contains hidden or 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
| # http://docs.python-requests.org/en/latest/ | |
| import requests | |
| from datetime import datetime, timedelta | |
| domain_name = 'domain' | |
| username = 'username' | |
| password = 'password' | |
| # lookup past 3 days along with today in case someone left a timer running | |
| today = datetime.now() |
This file contains hidden or 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 UserDetailAccessMixin(UserPassesTestMixin): | |
| def test_func(self, user): | |
| """ | |
| Tests if user should be allowed access to DetailView if one of two conditions: | |
| 1. Has staff permissions | |
| 2. Is the customer associated with the object in a DetailView | |
| """ | |
| if user.is_staff: | |
| return True | |
| else: |