├── README.md └── tutorial ├── dashboard ├── __init__.py ├── __init__.pyc ├── admin.py ├── admin.pyc ├── apps.py ├── apps.pyc ├── managers.py ├── managers.pyc ├── migrations │ ├── 0001_initial.py │ ├── 0001_initial.pyc │ ├── __init__.py │ └── __init__.pyc ├── models.py ├── models.pyc ├── tests.py └── views.py ├── db.sqlite3 ├── manage.py └── tutorial ├── __init__.py ├── __init__.pyc ├── settings.py ├── settings.pyc ├── urls.py ├── urls.pyc ├── wsgi.py └── wsgi.pyc /README.md: -------------------------------------------------------------------------------- 1 | # django-activity-stream-tutorial 2 | An easy tutorial for Jumpstarting the activity streams using Django for creating Website Dashboards. 3 | Entire tutorial description can be found at this link. 4 | 5 | https://impythonist.wordpress.com/2015/01/18/implementing-activity-streams-in-django-web-framework/ 6 | -------------------------------------------------------------------------------- /tutorial/dashboard/__init__.py: -------------------------------------------------------------------------------- 1 | default_app_config = 'dashboard.apps.MyAppConfig' -------------------------------------------------------------------------------- /tutorial/dashboard/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/__init__.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /tutorial/dashboard/admin.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/admin.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | from actstream import registry 3 | from django.contrib.auth.models import User 4 | 5 | class MyAppConfig(AppConfig): 6 | name = 'dashboard' 7 | def ready(self): 8 | registry.register(User,self.get_model('Task'),self.get_model('Supervisor')) -------------------------------------------------------------------------------- /tutorial/dashboard/apps.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/apps.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/managers.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from django.contrib.contenttypes.models import ContentType 3 | from actstream.managers import ActionManager, stream 4 | 5 | class MyActionManager(ActionManager): 6 | @stream 7 | def mystream(self, obj, verb='posted', time=None): 8 | if time is None: 9 | time = datetime.now() 10 | return obj.actor_actions.filter(verb = verb, timestamp__lte = time) -------------------------------------------------------------------------------- /tutorial/dashboard/managers.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/managers.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | from django.db import models, migrations 5 | from django.conf import settings 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Supervisor', 17 | fields=[ 18 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), 19 | ], 20 | options={ 21 | }, 22 | bases=(models.Model,), 23 | ), 24 | migrations.CreateModel( 25 | name='Task', 26 | fields=[ 27 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), 28 | ('name', models.CharField(max_length=100)), 29 | ('description', models.TextField(null=True, blank=True)), 30 | ], 31 | options={ 32 | }, 33 | bases=(models.Model,), 34 | ), 35 | migrations.AddField( 36 | model_name='supervisor', 37 | name='task', 38 | field=models.ManyToManyField(related_name='tasks', to='dashboard.Task'), 39 | preserve_default=True, 40 | ), 41 | migrations.AddField( 42 | model_name='supervisor', 43 | name='user', 44 | field=models.ForeignKey(related_name='supervisor', blank=True, to=settings.AUTH_USER_MODEL, null=True), 45 | preserve_default=True, 46 | ), 47 | ] 48 | -------------------------------------------------------------------------------- /tutorial/dashboard/migrations/0001_initial.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/migrations/0001_initial.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/migrations/__init__.py -------------------------------------------------------------------------------- /tutorial/dashboard/migrations/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/migrations/__init__.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/models.py: -------------------------------------------------------------------------------- 1 | #dashboard.models 2 | from django.db import models 3 | from django.contrib.auth.models import User 4 | # Create your models here. 5 | class Task(models.Model): 6 | name = models.CharField(max_length=100) 7 | description = models.TextField(null=True,blank=True) 8 | 9 | def __unicode__(self): 10 | return self.name 11 | 12 | 13 | class Supervisor(models.Model): 14 | user = models.ForeignKey(User,null=True,blank=True,related_name="supervisor") 15 | task = models.ManyToManyField(Task,related_name='tasks') 16 | 17 | def __unicode__(self): 18 | return self.user.username -------------------------------------------------------------------------------- /tutorial/dashboard/models.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/dashboard/models.pyc -------------------------------------------------------------------------------- /tutorial/dashboard/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /tutorial/dashboard/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /tutorial/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/db.sqlite3 -------------------------------------------------------------------------------- /tutorial/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /tutorial/tutorial/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/tutorial/__init__.py -------------------------------------------------------------------------------- /tutorial/tutorial/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/tutorial/__init__.pyc -------------------------------------------------------------------------------- /tutorial/tutorial/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for tutorial project. 3 | 4 | For more information on this file, see 5 | https://docs.djangoproject.com/en/1.7/topics/settings/ 6 | 7 | For the full list of settings and their values, see 8 | https://docs.djangoproject.com/en/1.7/ref/settings/ 9 | """ 10 | 11 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 12 | import os 13 | BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 14 | 15 | 16 | # Quick-start development settings - unsuitable for production 17 | # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ 18 | 19 | # SECURITY WARNING: keep the secret key used in production secret! 20 | SECRET_KEY = 'xsisbfp784n9a2tjkchrmspa&(zdhi0w!ay%)q!bknc54*&ch6' 21 | 22 | # SECURITY WARNING: don't run with debug turned on in production! 23 | DEBUG = True 24 | 25 | TEMPLATE_DEBUG = True 26 | 27 | ALLOWED_HOSTS = [] 28 | 29 | 30 | # Application definition 31 | 32 | INSTALLED_APPS = ( 33 | 'django.contrib.admin', 34 | 'django.contrib.auth', 35 | 'django.contrib.contenttypes', 36 | 'django.contrib.sessions', 37 | 'django.contrib.messages', 38 | 'django.contrib.staticfiles', 39 | 'dashboard', 40 | 'actstream', 41 | ) 42 | 43 | MIDDLEWARE_CLASSES = ( 44 | 'django.contrib.sessions.middleware.SessionMiddleware', 45 | 'django.middleware.common.CommonMiddleware', 46 | 'django.middleware.csrf.CsrfViewMiddleware', 47 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 48 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ) 52 | 53 | ROOT_URLCONF = 'tutorial.urls' 54 | 55 | WSGI_APPLICATION = 'tutorial.wsgi.application' 56 | 57 | 58 | # Database 59 | # https://docs.djangoproject.com/en/1.7/ref/settings/#databases 60 | 61 | DATABASES = { 62 | 'default': { 63 | 'ENGINE': 'django.db.backends.sqlite3', 64 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 65 | } 66 | } 67 | 68 | # Internationalization 69 | # https://docs.djangoproject.com/en/1.7/topics/i18n/ 70 | 71 | ACTSTREAM_SETTINGS = { 72 | 'MANAGER': 'dashboard.managers.MyActionManager', 73 | 'FETCH_RELATIONS': True, 74 | 'USE_PREFETCH': True, 75 | 'USE_JSONFIELD': False, 76 | 'GFK_FETCH_DEPTH': 1, 77 | } 78 | 79 | 80 | LANGUAGE_CODE = 'en-us' 81 | 82 | TIME_ZONE = 'UTC' 83 | 84 | USE_I18N = True 85 | 86 | USE_L10N = True 87 | 88 | USE_TZ = True 89 | 90 | 91 | # Static files (CSS, JavaScript, Images) 92 | # https://docs.djangoproject.com/en/1.7/howto/static-files/ 93 | 94 | STATIC_URL = '/static/' 95 | -------------------------------------------------------------------------------- /tutorial/tutorial/settings.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/tutorial/settings.pyc -------------------------------------------------------------------------------- /tutorial/tutorial/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | from django.contrib import admin 3 | 4 | urlpatterns = patterns('', 5 | # Examples: 6 | # url(r'^$', 'tutorial.views.home', name='home'), 7 | # url(r'^blog/', include('blog.urls')), 8 | 9 | url(r'^admin/', include(admin.site.urls)), 10 | ) 11 | -------------------------------------------------------------------------------- /tutorial/tutorial/urls.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/tutorial/urls.pyc -------------------------------------------------------------------------------- /tutorial/tutorial/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for tutorial project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings") 12 | 13 | from django.core.wsgi import get_wsgi_application 14 | application = get_wsgi_application() 15 | -------------------------------------------------------------------------------- /tutorial/tutorial/wsgi.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/narenaryan/django-activity-stream-tutorial/43ae21fb3c944349b16a0622d3bb517fcd279d32/tutorial/tutorial/wsgi.pyc --------------------------------------------------------------------------------