Example #1
0
from django.contrib.auth.models import User

import datetime
from pirate_signals.models import notification_send

from django.shortcuts import get_object_or_404
from django.db.models import Q

from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator

register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_messages')


@block
def pp_get_messages(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    sender = kwargs.get('sender', None)
    user = kwargs.get('user', None)
    start = kwargs.get('start', 0)
    end = kwargs.get('end', 10)
    newest = kwargs.get('newest', None)

    if sender is not None:
Example #2
0
from django import template
from django import forms
from django.http import HttpResponseRedirect

from pirate_social.models import Subscription,RelationshipEvent

from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_feed')

@block
def pp_get_feed(context, nodelist, *args, **kwargs):
    
    """
    This function get's recent feeds from a user's Subscriptions, with minimal
    unnecessary database calls. This function could be further optimized however.
    {% pp_get_feed user=request.user %}
        {% for f in pp_feed.feed %}
            {{f}}
        {% endfor %}
    {% endpp_get_feed %}"""
    
    context.push()
    namespace = get_namespace(context)

    user = kwargs.pop('user', None)
    subs = Subscription.objects.all()
Example #3
0
from markitup.widgets import MarkItUpWidget

from pirate_topics.models import Topic, MyGroup, GroupSettings, get_root
from pirate_core.views import namespace_get

from django.utils.html import urlize

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

from pirate_forum.models import get_rangelist


get_namespace = namespace_get('pp_topic')


@block
def pp_get_topic_if_content(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.pop('object', None)

    ctype_obj = ContentType.objects.get_for_model(obj)
    ctype = ContentType.objects.get_for_model(Topic)

    ret = None
    if ctype == ctype_obj:
Example #4
0
from pirate_messages.tasks import set_to_read

from collections import defaultdict
import datetime
from pirate_signals.models import notification_send

from django.shortcuts import get_object_or_404

from pirate_core.views import HttpRedirectException, namespace_get
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_messages')


@block
def pp_has_mail(context, nodelist, *args, **kwargs):
    context.push()
    namespace = get_namespace(context)

    user = kwargs.get('user', None)

    notes = Notification.objects.filter(receiver=user, is_read=False)

    unread = Message.objects.filter(read=False, receiver=user)

    count = len(notes) + len(unread)
Example #5
0
from markdown import markdown

import datetime
from pirate_signals.models import notification_send, relationship_event, aso_rep_event

from django.shortcuts import get_object_or_404

from pirate_core.views import HttpRedirectException, namespace_get


from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_comment')


@block
def pp_comment_count(context, nodelist, *args, **kwargs): 
    context.push()
    namespace = get_namespace(context)

    object_pk = kwargs.get('object', None)
    comments = Comment.objects.all()
    count = len(list(comments.filter(object_pk=object_pk)))
    namespace['count'] = count

    output = nodelist.render(context)
    context.pop()
Example #6
0
from django.http import HttpResponse, HttpResponseRedirect
from django.utils import simplejson
from pirate_consensus.models import Consensus

from django.shortcuts import get_object_or_404
from django.contrib.contenttypes.models import ContentType

from pirate_core.views import HttpRedirectException, namespace_get
from pirate_signals.models import aso_rep_event
from pirate_reputation.models import ReputationDimension

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_flag')

@block
def pp_flag_form(context, nodelist, *args, **kwargs): 

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.pop('object', None)
    POST = kwargs.pop('POST', None)
    user = kwargs.get('user', None)
    PI = kwargs.get('PATH_INFO',None)
    QS = kwargs.get('QUERY_STRING',None)
    path = PI + '?' + QS
    
    if POST is not None and POST.get("form_id") == "pp_flag_form":
Example #7
0
from django import forms
from django import template
from pirate_core.views import namespace_get
from pirate_core.forms import FormMixin
from pirate_permissions.models import PermissionsGroup, Permission

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get("pp_permissions")


@block
def has_permissions(context, nodelist, *args, **kwargs):
    """Returns a list of users with the permission applied to the object.

    """
    context.push()
    namespace = get_namespace(context)

    name = kwargs.pop('name', None)
    obj = kwargs.pop('object', None)

    try:
        attempt = obj.is_authenticated()
    except:
        attempt = True
    if attempt:
        perm = Permission.objects.filter(name=name, object_pk=obj.pk)
Example #8
0
from django.core.urlresolvers import reverse
import re
from django.core.cache import cache
from py_etherpad import EtherpadLiteClient
import datetime

from settings import ETHERPAD_API
from filetransfers.api import prepare_upload

from django.conf import settings

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_source')


@block
def pp_set_livestreamcache(context, nodelist, *args, **kwargs):
	"""
	Retrieves the current image for this object id.
	"""
	context.push()
	namespace = get_namespace(context)

	user = kwargs.get('user', None)
	obj = kwargs.get('object', None)

	cache.set(str(user.pk) + '-livestream', obj.pk)
	output = nodelist.render(context)
Example #9
0
from markdown import markdown

import datetime
from pirate_signals.models import notification_send, relationship_event, aso_rep_event

from django.shortcuts import get_object_or_404

from pirate_core.views import HttpRedirectException, namespace_get


from customtags.decorators import block_decorator

register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get("pp_comment")


@block
def pp_comment_count(context, nodelist, *args, **kwargs):
    context.push()
    namespace = get_namespace(context)

    object_pk = kwargs.get("object", None)
    comments = Comment.objects.all()
    count = len(list(comments.filter(object_pk=object_pk)))
    namespace["count"] = count

    output = nodelist.render(context)
    context.pop()
Example #10
0
from django import template
from django import forms
from django.http import HttpResponseRedirect

from pirate_social.models import Subscription, RelationshipEvent

from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_feed')


@block
def pp_get_feed(context, nodelist, *args, **kwargs):
    """
    This function get's recent feeds from a user's Subscriptions, with minimal
    unnecessary database calls. This function could be further optimized however.
    {% pp_get_feed user=request.user %}
        {% for f in pp_feed.feed %}
            {{f}}
        {% endfor %}
    {% endpp_get_feed %}"""

    context.push()
    namespace = get_namespace(context)

    user = kwargs.pop('user', None)
    subs = Subscription.objects.all()
Example #11
0
from oa_location.models import LocationForm, Place
import random
import math
from django.db.models import Count

import pygeoip
from settings import GEOIP_PATH
from geopy import geocoders 

from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('oa_loc')


@block
def oa_location_form(context, nodelist, *args, **kwargs):

	context.push()
	namespace = get_namespace(context)

	request = kwargs.get('request', None)
	obj = kwargs.get('object', None)
	user = kwargs.get('user', None)
	POST = kwargs.get('POST', None)
	start = kwargs.get('start', 0)
	end = kwargs.get('end', 5)
	
Example #12
0
from markdown import markdown

import datetime
from pirate_signals.models import notification_send, relationship_event, aso_rep_event

from django.shortcuts import get_object_or_404

from pirate_core.views import HttpRedirectException, namespace_get


from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_comment')


@block
def pp_comment_count(context, nodelist, *args, **kwargs): 
    context.push()
    namespace = get_namespace(context)

    object_pk = kwargs.get('object', None)
    comments = Comment.objects.all()
    count = len(list(comments.filter(object_pk=object_pk)))
    namespace['count'] = count

    output = nodelist.render(context)
    context.pop()
Example #13
0
from markitup.widgets import MarkItUpWidget

from pirate_topics.models import Topic, MyGroup, GroupSettings, get_root
from pirate_core.views import namespace_get

from django.utils.html import urlize

from customtags.decorators import block_decorator

register = template.Library()
block = block_decorator(register)

from pirate_forum.models import get_rangelist

get_namespace = namespace_get('pp_topic')


@block
def pp_get_topic_if_content(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.pop('object', None)

    ctype_obj = ContentType.objects.get_for_model(obj)
    ctype = ContentType.objects.get_for_model(Topic)

    ret = None
    if ctype == ctype_obj:
Example #14
0
SPECTRUM_COLORS = {
    1: "#e11010",
    2: "#e13310",
    3: "#e15610",
    4: "#e17810",
    5: "#e19b10",
    6: "#e1be10",
    7: "#e1e110",
    8: "#bee110",
    9: "#9be110",
    10: "#78e110",
    11: "#56e110",
}

get_namespace = namespace_get('pp_consensus')



class RatingForm(forms.Form):
    form_id = forms.CharField(widget=forms.HiddenInput(), initial="pp_rating_form")
    rating = forms.ChoiceField(choices=RATINGS_CHOICES)
    
class SpectrumForm(forms.Form):
    form_id = forms.CharField(widget=forms.HiddenInput(), initial="pp_spectrum_form")
    spectrum = forms.ChoiceField(choices=SPECTRUM_CHOICES.items())


@block
def pp_get_ranked_decision(context, nodelist, *args, **kwargs):
Example #15
0
from django.utils import simplejson
from pirate_consensus.models import Consensus

from django.shortcuts import get_object_or_404
from django.contrib.contenttypes.models import ContentType

from pirate_core.views import HttpRedirectException, namespace_get
from pirate_signals.models import aso_rep_event
from pirate_reputation.models import ReputationDimension

from customtags.decorators import block_decorator

register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_flag')


@block
def pp_flag_form(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.pop('object', None)
    POST = kwargs.pop('POST', None)
    user = kwargs.get('user', None)
    PI = kwargs.get('PATH_INFO', None)
    QS = kwargs.get('QUERY_STRING', None)
    path = PI + '?' + QS
Example #16
0
SPECTRUM_COLORS = {
    1: "#e11010",
    2: "#e13310",
    3: "#e15610",
    4: "#e17810",
    5: "#e19b10",
    6: "#e1be10",
    7: "#e1e110",
    8: "#bee110",
    9: "#9be110",
    10: "#78e110",
    11: "#56e110",
}

get_namespace = namespace_get('pp_consensus')


@block
def pp_get_ranked_decision(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.pop('object', None)

    try:
        rv = RankedDecision.objects.get(parent=obj)
    except:
        rv = None
Example #17
0
from django.core.urlresolvers import reverse
import re
from django.core.cache import cache
from py_etherpad import EtherpadLiteClient
import datetime

from settings import ETHERPAD_API
from filetransfers.api import prepare_upload

from django.conf import settings

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_source')


@block
def pp_set_livestreamcache(context, nodelist, *args, **kwargs):
    """
    Retrieves the current image for this object id.
    """
    context.push()
    namespace = get_namespace(context)

    user = kwargs.get('user', None)
    obj = kwargs.get('object', None)

    cache.set(str(user.pk) + '-livestream', obj.pk)
    output = nodelist.render(context)
Example #18
0
import random
import math
from django.db.models import Count

import pygeoip
from settings import GEOIP_PATH
from geopy import geocoders

from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator

register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('oa_loc')


@block
def oa_location_form(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    request = kwargs.get('request', None)
    obj = kwargs.get('object', None)
    user = kwargs.get('user', None)
    POST = kwargs.get('POST', None)
    start = kwargs.get('start', 0)
    end = kwargs.get('end', 5)
Example #19
0
from django import forms
from django import template
from pirate_core.views import namespace_get
from pirate_core.forms import FormMixin
from pirate_permissions.models import PermissionsGroup, Permission

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)


get_namespace = namespace_get("pp_permissions")


@block
def has_permissions(context, nodelist, *args, **kwargs):
    """Returns a list of users with the permission applied to the object.

    """
    context.push()
    namespace = get_namespace(context)

    name = kwargs.pop('name', None)
    obj = kwargs.pop('object', None)

    try:
        attempt = obj.is_authenticated()
    except:
        attempt = True
    if attempt:
        perm = Permission.objects.filter(name=name, object_pk=obj.pk)
Example #20
0
from django.utils import simplejson
from django.db import transaction
from django.middleware import csrf
from django.contrib.contenttypes.models import ContentType
from pirate_actions.models import Action, ActionForm
from django.contrib.auth.models import User
from django.db.models import Count
import datetime
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from pirate_core.views import HttpRedirectException, namespace_get

from customtags.decorators import block_decorator
register = template.Library()
block = block_decorator(register)

get_namespace = namespace_get('pp_action')


@block
def pp_action_form(context, nodelist, *args, **kwargs):

    context.push()
    namespace = get_namespace(context)

    obj = kwargs.get('object', None)
    user = kwargs.get('user', None)
    POST = kwargs.get('POST', None)

    if POST and POST.get("form_id") == "pp_action_form":
        form = ActionForm(POST)
        #if form is valid frab the lat/long from the geolocation service