Skip to content

Instantly share code, notes, and snippets.

View mitchdowney's full-sized avatar
🌎
hello world

Mitch Downey mitchdowney

🌎
hello world
View GitHub Profile
{% extends "account/base.html" %}
{% load i18n %}
{% load account %}
{% load url from future %}
{% block head_title %}{% trans "Signup" %}{% endblock %}
{% block content %}
@mitchdowney
mitchdowney / gist:10145492
Created April 8, 2014 15:44
how do i filter the models to pass all quotes from one podcast?
class Podcast(models.Model):
title = models.CharField(max_length=200)
description = models.TextField(blank=True)
image = models.FileField(upload_to=get_upload_file_name, blank=True)
homepage = models.URLField(blank=True)
donate_url = models.URLField(blank=True)
# categories = ...
# keywords = ...
# followers = ...
@mitchdowney
mitchdowney / views.py
Created April 9, 2014 23:47
form, need to add a get or create function for Tag and PersonQuoted
def quote_create(request):
if request.method == "POST":
pform = PersonQuotedCreateForm(request.POST, instance=PersonQuoted())
tform = TagCreateForm(request.POST, instance=Tag())
qform = QuoteCreateForm(request.POST, instance=Quote())
if pform.is_valid() and tform.is_valid() and qform.is_valid():
new_personquoted = pform.save()
new_tag = tform.save()
new_quote = qform.save()
return HttpResponseRedirect('/')
podcast.title = feed['title']
podcast.description = feed['description']
podcast.homepage = feed['homepage']
if feed['keywords_list'] == '':
pass
else:
keywords_list = feed['keywords_list']
# remove duplicates from keywords_list
@mitchdowney
mitchdowney / podcast.py
Created June 17, 2014 19:10
podcast.py
# Map feed information to Podcast
podcast.title = feed['title']
podcast.description = feed['description']
podcast.homepage = feed['homepage']
if feed['keywords_list'] == '':
pass
else:
keywords_list = feed['keywords_list']
@mitchdowney
mitchdowney / opengraph
Created June 30, 2014 05:31
wtf opengraph?
<!DOCTYPE html>
<html lang="en-US" prefix="og: http://ogp.me/ns#" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#">
<head>
<meta charset=”utf-8”>
{% block head_title %}
<title>Podverse - Find and share podcast highlights</title>
{% endblock %}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Find and share highlights of your favorite podcasts. Connect with podcast listeners. Raise money for your podcast. Inspired by reddit.">
<link rel="publisher" href="">
candidates.py
class CandidateDetailView(DetailView):
model = Candidate
context_object_name = 'candidate'
def get_context_data(self, **kwargs):
context = super(CandidateDetailView, self).get_context_data(**kwargs)
context['election'] = self.get_object().election
context['previous_candidates'] = Candidate.objects.order_by('id').filter(election_id=self.get_object().election.id).filter(is_approved=True).filter(id__lt=self.get_object().id)
context['next_candidates'] = Candidate.objects.order_by('id').filter(election_id=self.get_object().election.id).filter(is_approved=True).filter(id__gt=self.get_object().id)
@mitchdowney
mitchdowney / template.html
Last active December 24, 2015 20:39
See anything wrong with this Bootstrap typeahead?
<head>
<script type="text/javascript">
$('.searchAhead').typeahead({
source: function(query, process) {
return $.get('/lookup/university/', { query: query }, function (data) {
return process(data.options);
});
}
});
</script>
@mitchdowney
mitchdowney / json_example
Created October 7, 2013 00:43
Now when I type anything into the typeahead box, the dropdown with query results appears and says "undefined"
When I visit the following URL http://127.0.0.1:8000/lookup/universities/?query=K
The page displays the following text:
{"options": ["Kenny University", "Kent State"]}
@mitchdowney
mitchdowney / playlist.json
Created February 9, 2016 04:16
what's an efficient way to POST playlists to the web app?
{
playlist: {
episode: {
title: "#265 - The episode where some stuff happened",
duration: "50:25",
pubDate: "2016-02-07 22:30:55 +0000",
podcast: {
title: "The Best Podcast Ever Show"
}
},