forked from simeonf/pybay
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding featured speakers app * Add featured_speakers and dependency to INSTALLED_APPS * Add changes to frontend template * Use name in admin dropdown list * One row, many speakers * Many hoops to customize the string display of Speaker model in admain
- Loading branch information
Showing
14 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django import forms | ||
from django.contrib import admin | ||
from django.db import models | ||
|
||
from ordered_model.admin import OrderedModelAdmin | ||
|
||
from .models import FeaturedSpeaker | ||
from symposion.speakers.models import Speaker | ||
|
||
class SpeakerChoiceField(forms.ModelChoiceField): | ||
"""Class to overwrite __str__ implementation on speakers and provide text in dropdown.""" | ||
def label_from_instance(self, obj): | ||
return obj.name | ||
|
||
class FeaturedSpeakerForm(forms.ModelForm): | ||
speaker = SpeakerChoiceField(Speaker.objects.all()) | ||
|
||
class FeaturedSpeakerAdmin(OrderedModelAdmin): | ||
list_display = ('title', 'speaker_name', 'move_up_down_links') | ||
form = FeaturedSpeakerForm | ||
def speaker_name(self, obj): | ||
return obj.speaker.name | ||
speaker_name.admin_order_field = 'speaker' | ||
|
||
|
||
|
||
admin.site.register(FeaturedSpeaker, FeaturedSpeakerAdmin) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class FeaturedSpeakersConfig(AppConfig): | ||
name = 'featured_speakers' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.2 on 2017-06-21 02:54 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('symposion_speakers', '0003_auto_20170419_0518'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='FeaturedSpeaker', | ||
fields=[ | ||
('order', models.PositiveIntegerField(db_index=True, editable=False)), | ||
('title', models.CharField(max_length=50)), | ||
('speaker', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='symposion_speakers.Speaker')), | ||
], | ||
options={ | ||
'ordering': ('order',), | ||
'abstract': False, | ||
}, | ||
), | ||
] |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.db import models | ||
|
||
from ordered_model.models import OrderedModel | ||
from symposion.speakers.models import Speaker | ||
|
||
|
||
class FeaturedSpeaker(OrderedModel): | ||
title = models.CharField(max_length=50) | ||
speaker = models.OneToOneField(Speaker, on_delete=models.CASCADE, primary_key=True) | ||
|
||
class Meta(OrderedModel.Meta): | ||
pass |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="main-container"> | ||
<section class="speakers duplicatable-content"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<h1>Some of our speakers.</h1> | ||
</div> | ||
</div> | ||
<div class="row speakers-row"> | ||
{% for featured in speakers %} | ||
<div class="col-md-3 col-sm-6 speaker-column"> | ||
<div class="speaker"> | ||
{% if featured.speaker.photo %} | ||
<div class="image-holder"> | ||
<img class="background-image" alt="Speaker" src="{{ MEDIA_URL }}{{ featured.speaker.photo.name }}"> | ||
<div class="hover-state text-center preserve3d"> | ||
<div class="social-links vertical-align"> | ||
{% if featured.speaker.twitter_username %} | ||
<a href="http://twitter.com/{{ featured.speaker.twitter_username }}"><i class="icon social_twitter"></i></a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
<span class="speaker-name">{{ featured.speaker.name }}</span> | ||
{{ featured.speaker.biography_html|safe }} | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</section> | ||
</div> |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django import template | ||
|
||
from featured_speakers.models import FeaturedSpeaker | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.inclusion_tag('featured_speakers/list.html', takes_context=True) | ||
def featured_speakers(context): | ||
context['speakers'] = FeaturedSpeaker.objects.all() | ||
return context |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
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
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
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