Example #1
0
import twitter
import urllib
from datetime import datetime

from django.db.utils import IntegrityError
from django.http import HttpResponse
from django.views.generic import TemplateView, View
from rest_framework import generics, viewsets

from socialtool.loading import get_classes, get_model


PostSerializer, PaginatedPostSerializer, MessageSerializer, \
MarketAccountSerializer = get_classes('social.serializers', ('PostSerializer', 'PaginatedPostSerializer', 'MessageSerializer', 'MarketAccountSerializer'))

HasImageFilterBackend, OldSchoolRetweet = get_classes('social.filters', ('HasImageFilterBackend', 'OldSchoolRetweet'))

# TODO - tweet and artworker assignments should be returning a JSON
# response - although having said that we are just swapping out HTML
# for returned HTML - so maybe not! ~jaymz


class TweetUserView(TemplateView):
    template_name = 'tweet_user.html'

    def send_tweet(self):
        tweet_pk = self.request.GET['tweet_pk']
        msg = self.request.GET['msg']

        tweet = get_model('social', 'socialpost').objects.get(pk=tweet_pk)
Example #2
0
from django.contrib import admin
from django.utils.safestring import mark_safe
from socialtool.loading import get_classes, get_model

SocialPostImageFilter, SocialPostStatusFilter = get_classes('social.filters',
('SocialPostImageFilter', 'SocialPostStatusFilter'))

# Register your models here.

def mark_deleted(modeladmin, request, queryset):
    queryset.update(deleted=True)
mark_deleted.short_description = 'Hide selected posts'

def mark_approved(modeladmin, request, queryset):
    queryset.update(approved=True)
mark_approved.short_description = 'Mark selected posts as approved'


class BaseAdmin(admin.ModelAdmin):

    class Media:
        js = ('js/tweet_admin.js', )
        css = {
            'all': ('css/adi051.css', )
        }


class SocialAdmin(BaseAdmin):
    search_fields = ('handle', 'content',)
    list_display = ('created_at', 'high_priority', 'get_handle', 'post_source', 'get_image', 'content', 'messages', 'notes')
    list_filter = ('account', 'search_term', 'high_priority', SocialPostStatusFilter, SocialPostImageFilter, 'created_at', 'entry_allowed')
from django.db import models
from django.contrib.auth.models import User
from socialtool.loading import get_classes, get_model

SocialPostManager, AllSocialPostManager = get_classes(
    'social.managers', ('SocialPostManager', 'AllSocialPostManager'))


class AbstractMarketAccount(models.Model):
    """
        This model allows us to actual query the social networks and interact
        with them.
    """
    ACCOUNT_CHOICES = (
        ('twitter', 'Twitter'),
        ('instagram', 'Instagram'),
    )

    type = models.CharField(max_length=50,
                            unique=True,
                            choices=ACCOUNT_CHOICES)
    handle = models.CharField(max_length=100)
    active = models.BooleanField(default=True)

    # Optionally associate with a particular user for filtering/ACL
    user = models.ForeignKey(User, blank=True, null=True)

    # Instagram
    client_id = models.CharField(max_length=100, blank=True, null=True)
    client_secret = models.CharField(max_length=100, blank=True, null=True)
Example #4
0
from django.conf import settings
from django.conf.urls import patterns, include, url, static
from django.contrib import admin
from rest_framework import routers
from socialtool.loading import get_classes

TweetUserView, BanUserView, PaginatedImagePostFeedView, \
MessageViewSet, MarketAccountViewSet = get_classes('social.views',
('TweetUserView', 'BanUserView', 'PaginatedImagePostFeedView',
'MessageViewSet', 'MarketAccountViewSet'))


admin.autodiscover()
router = routers.DefaultRouter()
router.register(r'messages', MessageViewSet)
router.register(r'accounts', MarketAccountViewSet)

urlpatterns = patterns('',
    url(r'^', include(admin.site.urls)),
    url(r'^api/', include(router.urls)),
    url(r'^send-tweet/', TweetUserView.as_view(), name='tweet_user'),
    url(r'^ban-user/', BanUserView.as_view(), name='ban_user'),
    url(r'^api/image-feed/', PaginatedImagePostFeedView.as_view(), name='image_feed'),
) + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #5
0
from django.conf import settings
from django.conf.urls import patterns, include, url, static
from django.contrib import admin
from rest_framework import routers
from socialtool.loading import get_classes

TweetUserView, BanUserView, PaginatedImagePostFeedView, \
MessageViewSet, MarketAccountViewSet = get_classes('social.views',
                                                     ('TweetUserView', 'BanUserView', 'PaginatedImagePostFeedView',
                                                      'MessageViewSet', 'MarketAccountViewSet'))

admin.autodiscover()
router = routers.DefaultRouter()
router.register(r'messages', MessageViewSet)
router.register(r'accounts', MarketAccountViewSet)

urlpatterns = patterns(
    '',
    url(r'^', include(admin.site.urls)),
    url(r'^api/', include(router.urls)),
    url(r'^send-tweet/', TweetUserView.as_view(), name='tweet_user'),
    url(r'^ban-user/', BanUserView.as_view(), name='ban_user'),
    url(r'^api/image-feed/',
        PaginatedImagePostFeedView.as_view(),
        name='image_feed'),
) + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.db import models
from django.contrib.auth.models import User
from socialtool.loading import get_classes, get_model

SocialPostManager, AllSocialPostManager = get_classes('social.managers', ('SocialPostManager', 'AllSocialPostManager'))


class AbstractMarketAccount(models.Model):
    """
        This model allows us to actual query the social networks and interact
        with them.
    """
    ACCOUNT_CHOICES = (
        ('twitter', 'Twitter'),
        ('instagram', 'Instagram'),
    )

    type = models.CharField(max_length=50, unique=True, choices=ACCOUNT_CHOICES)
    handle = models.CharField(max_length=100)
    active = models.BooleanField(default=True)

    # Optionally associate with a particular user for filtering/ACL
    user = models.ForeignKey(User, blank=True, null=True)

    # Instagram
    client_id = models.CharField(max_length=100, blank=True, null=True)
    client_secret = models.CharField(max_length=100, blank=True, null=True)

    # Twitter
    consumer_secret = models.CharField(max_length=100, blank=True, null=True)
    consumer_key = models.CharField(max_length=100, blank=True, null=True)
Example #7
0
from django.contrib import admin
from django.utils.safestring import mark_safe
from socialtool.loading import get_classes, get_model

SocialPostImageFilter, SocialPostStatusFilter = get_classes(
    'social.filters', ('SocialPostImageFilter', 'SocialPostStatusFilter'))

# Register your models here.


def mark_deleted(modeladmin, request, queryset):
    queryset.update(deleted=True)


mark_deleted.short_description = 'Hide selected posts'


def mark_approved(modeladmin, request, queryset):
    queryset.update(approved=True)


mark_approved.short_description = 'Mark selected posts as approved'


class BaseAdmin(admin.ModelAdmin):
    class Media:
        js = ('js/tweet_admin.js', )
        css = {'all': ('css/adi051.css', )}


class SocialAdmin(BaseAdmin):