mirror of
https://github.com/hellosteadman/bambu-buffer.git
synced 2025-05-05 00:39:52 +00:00
Squashed commit of the following:
commit d8d30f35465f474923b31d6536dec5e1808fc940 Author: Mark <mark@steadman.io> Date: Sun Aug 10 10:55:57 2014 +0100 Removed reliance on created_at field
This commit is contained in:
parent
f281be79dd
commit
f080a5dc88
4 changed files with 10 additions and 17 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
|
bambu_buffer.egg-info
|
||||||
|
dist
|
||||||
|
|
|
@ -47,11 +47,6 @@ def post(item, author, **kwargs):
|
||||||
object_id = item.pk,
|
object_id = item.pk,
|
||||||
content_type = content_type
|
content_type = content_type
|
||||||
).exists():
|
).exists():
|
||||||
print '%s %d has already been sent to Buffer' % (
|
|
||||||
unicode(item._meta.verbose_name).capitalize(),
|
|
||||||
item.pk
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
BufferedItem.objects.create(
|
BufferedItem.objects.create(
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.timezone import pytz
|
from django.utils.timezone import now
|
||||||
from bambu_buffer.settings import PROFILES_URL, TIMEOUT
|
from bambu_buffer.settings import PROFILES_URL, TIMEOUT
|
||||||
from bambu_buffer import log
|
from bambu_buffer import log
|
||||||
from bambu_buffer.receivers import *
|
from bambu_buffer.receivers import *
|
||||||
from datetime import datetime, timedelta
|
|
||||||
import requests, json
|
import requests, json
|
||||||
|
|
||||||
class BufferToken(models.Model):
|
class BufferToken(models.Model):
|
||||||
|
@ -45,19 +44,10 @@ class BufferToken(models.Model):
|
||||||
|
|
||||||
services[service.remote_id] = service
|
services[service.remote_id] = service
|
||||||
|
|
||||||
epoch = datetime(1970, 1, 1, 0, 0, 0,
|
|
||||||
tzinfo = pytz.timezone(
|
|
||||||
profile['timezone']
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
service.profiles.create(
|
service.profiles.create(
|
||||||
avatar = profile.get('avatar_https',
|
avatar = profile.get('avatar_https',
|
||||||
profile.get('avatar')
|
profile.get('avatar')
|
||||||
),
|
),
|
||||||
created_at = epoch + timedelta(
|
|
||||||
seconds = profile['created_at']
|
|
||||||
),
|
|
||||||
default = profile['default'],
|
default = profile['default'],
|
||||||
selected = profile['default'],
|
selected = profile['default'],
|
||||||
formatted_username = profile['formatted_username'],
|
formatted_username = profile['formatted_username'],
|
||||||
|
@ -105,6 +95,12 @@ class BufferProfile(models.Model):
|
||||||
def icon(self):
|
def icon(self):
|
||||||
return self.service.icon
|
return self.service.icon
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if not self.created_at:
|
||||||
|
self.created_at = now()
|
||||||
|
|
||||||
|
super(BufferProfile, self).save(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'buffer_profile'
|
db_table = 'buffer_profile'
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ def post_save_receiver(sender, instance, **kwargs):
|
||||||
|
|
||||||
name = m.pop(0)
|
name = m.pop(0)
|
||||||
app, model = name.lower().split('.')
|
app, model = name.lower().split('.')
|
||||||
if app != instance._meta.app_label or model != instance._meta.module_name:
|
if app != type(instance)._meta.app_label or model != instance._meta.module_name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if any(m):
|
if any(m):
|
||||||
|
|
Loading…
Reference in a new issue