Navigation Menu

Skip to content

Commit

Permalink
Added a basic option to post to twitter via the admin (draftish)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Jan 21, 2011
1 parent e3f20bd commit d159d33
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions overseer/admin.py
@@ -1,22 +1,38 @@
from django import forms
from django.contrib import admin

from overseer import conf
from overseer.models import Service, Event, EventUpdate

class ServiceAdmin(admin.ModelAdmin):
list_display = ('name', 'status', 'order', 'date_updated')
search_fields = ('name', 'description')
prepopulated_fields = {'slug': ('name',)}

class EventForm(forms.ModelForm):
if conf.TWITTER_ACCESS_TOKEN and conf.TWITTER_ACCESS_SECRET:
post_to_twitter = forms.BooleanField(required=False, label="Post an update to Twitter when I hit save", help_text="This will send a tweet with a brief summary, the permalink to the event (if BASE_URL is defined), and the hashtag of #status")

class Meta:
model = EventUpdate

class EventUpdateInline(admin.StackedInline):
model = EventUpdate
extra = 1

class EventAdmin(admin.ModelAdmin):
form = EventForm
list_display = ('date_created', 'description', 'status', 'date_updated')
search_fields = ('description', 'message')
list_filter = ('services',)
inlines = [EventUpdateInline]

def save_formset(self, request, form, formset, change):
instances = formset.save()
if form.cleaned_data['post_to_twitter']:
for obj in instances:
obj.event.post_to_twitter(obj.get_message())

class EventUpdateAdmin(admin.ModelAdmin):
list_display = ('date_created', 'message', 'status', 'event')
search_fields = ('message',)
Expand Down

0 comments on commit d159d33

Please sign in to comment.