Beispiel #1
0
def social_share():
    orain = timezone.now()

    berriak = Berria.objects.filter(
        Q(pub_date__lte=orain) & Q(status='1')
        & Q(shared=False)).order_by('-pub_date')

    gpak = GamePlaya.objects.filter(
        Q(pub_date__lte=orain) & Q(status='1')
        & Q(shared=False)).order_by('-pub_date')

    atalak = Atala.objects.filter(
        Q(pub_date__lte=orain) & Q(publikoa_da=True)
        & Q(shared=False)).order_by('-pub_date')

    txak = Txapelketa.objects.filter(
        Q(pub_date__lte=orain) & Q(publikoa_da=True)
        & Q(shared=False)).order_by('-pub_date')

    for berria in berriak:
        post_social(berria)
        berria.shared = True
        berria.save()
        l = Log()
        l.mota = 'Albistea'
        l.tituloa = berria.izenburua
        l.fetxa = timezone.now()
        l.user = berria.erabiltzailea
        l.deskripzioa = filters.striptags(berria.desk)[:400] + '...'
        l.berria = berria
        l.save()

    for gp in gpak:
        post_social(gp)
        gp.shared = True
        gp.save()
        l = Log()
        l.mota = 'GP'
        l.tituloa = gp.izenburua
        l.fetxa = timezone.now()
        l.user = gp.erabiltzailea
        l.deskripzioa = filters.striptags(gp.desk)[:400] + '...'
        l.gameplaya = gp
        l.save()

    for atal in atalak:
        post_social(atal)
        atal.shared = True
        atal.save()

    for tx in txak:
        post_social(tx)
        tx.shared = True
        tx.save()

    return True
def social_share():
    orain = datetime.datetime.now()

    berriak = Berria.objects.filter(Q(pub_date__lte=orain) & Q(status='1')
                                   & Q(shared=False)).order_by('-pub_date')

    gpak = GamePlaya.objects.filter(Q(pub_date__lte=orain) & Q(status='1')
                                   & Q(shared=False)).order_by('-pub_date')

    atalak = Atala.objects.filter(Q(pub_date__lte=orain) & Q(publikoa_da=True)
                                   & Q(shared=False)).order_by('-pub_date')

    txak = Txapelketa.objects.filter(Q(pub_date__lte=orain) & Q(publikoa_da=True)
                                    & Q(shared=False)).order_by('-pub_date')
    
    for berria in berriak:
        post_social(berria)
        berria.shared=True
        berria.save()
        l = Log()
        l.mota = 'Albistea'
        l.tituloa = berria.izenburua
        l.fetxa =datetime.datetime.now()
        l.user = berria.erabiltzailea
        l.deskripzioa = filters.striptags(berria.desk)[:400]+'...'
        l.berria = berria
        l.save()        
    
    for gp in gpak:
        post_social(gp)
        gp.shared=True
        gp.save()
        l = Log()
        l.mota = 'GP'
        l.tituloa = gp.izenburua
        l.fetxa =datetime.datetime.now()
        l.user = gp.erabiltzailea
        l.deskripzioa = filters.striptags(gp.desk)[:400]+'...'
        l.gameplaya = gp
        l.save()

    for atal in atalak:
        post_social(atal)
        atal.shared=True
        atal.save()

    for tx in txak:
        post_social(tx)
        tx.shared=True
        tx.save()

    return True
Beispiel #3
0
def send_comment_email(sender,instance,**kwargs):
    if kwargs['created']:
        recipient_list = []
        message = 'Iruzkin berri bat utzi dute zuk iruzkindutako '
        messagelog = 'Iruzkin berria egin dute '
        ct = ContentType.objects.get_for_id(instance.content_type.id)
        obj = ct.get_object_for_this_type(pk=instance.object_pk)
        try:
            if obj.__class__.__name__ == 'Berria':
                message += 'artikulu honetan: \n\n%sbloga/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'artikulu honetan: \n\n%sbloga/%s\n\n' % (settings.HOST,obj.slug)
            elif obj.__class__.__name__ == 'Txapelketa':
                message += 'txapelketa honetan: \n\n%stxapelketak/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'txapelketa honetan: \n\n%stxapelketak/%s\n\n' % (settings.HOST,obj.slug)
            elif obj.__class__.__name__ == 'GamePlaya':
                message += 'gameplay honetan: \n\n%sgameplayak/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'gameplay honetan: \n\n%sgameplayak/%s\n\n' % (settings.HOST,obj.slug)
            creators = Comment.objects.filter(object_pk=instance.object_pk,content_type=instance.content_type).values('user__email').distinct()
            l = Log()
            l.mota = 'Iruzkin'
            l.tituloa = "Iruzkin berria"
            l.deskripzioa = messagelog
            l.save()

            for creator in creators:
                if not instance.user.email == creator['user__email'] and instance.user.email_notification:
                    send_mail('[Game Erauntsia - Iruzkin berria]', message, settings.DEFAULT_FROM_EMAIL, [creator['user__email']])
        except:
            send_mail('[Game Erauntsia]', str(instance.id)+' iruzkina ezin izan da bidali!\n\nMezua honako hau zen: "'+message+'"', settings.DEFAULT_FROM_EMAIL, ['*****@*****.**'])
Beispiel #4
0
def send_comment_email(sender,instance,**kwargs):
    if kwargs['created']:
        recipient_list = []
        message = 'Iruzkin berri bat utzi dute zuk iruzkindutako '
        messagelog = 'Iruzkin berria egin dute '
        ct = ContentType.objects.get_for_id(instance.content_type.id)
        obj = ct.get_object_for_this_type(pk=instance.object_pk)
        try:
            if obj.__class__.__name__ == 'Berria':
                message += 'artikulu honetan: \n\n%sbloga/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'artikulu honetan: \n\n%sbloga/%s\n\n' % (settings.HOST,obj.slug)
            elif obj.__class__.__name__ == 'Txapelketa':
                message += 'txapelketa honetan: \n\n%stxapelketak/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'txapelketa honetan: \n\n%stxapelketak/%s\n\n' % (settings.HOST,obj.slug)
            elif obj.__class__.__name__ == 'GamePlaya':
                message += 'gameplay honetan: \n\n%sgameplayak/%s\n\n' % (settings.HOST,obj.slug)
                messagelog += 'gameplay honetan: \n\n%sgameplayak/%s\n\n' % (settings.HOST,obj.slug)
            creators = Comment.objects.filter(object_pk=instance.object_pk,content_type=instance.content_type).values('user__email').distinct()
            l = Log()
            l.mota = 'Iruzkin'
            l.tituloa = "Iruzkin berria"
            l.deskripzioa = messagelog
            l.save()

            for creator in creators:
                if not instance.user.email == creator['user__email'] and instance.user.email_notification:
                    send_mail('[Game Erauntsia - Iruzkin berria]', message, settings.DEFAULT_FROM_EMAIL, [creator['user__email']])
        except:
            send_mail('[Game Erauntsia]', str(instance.id)+' iruzkina ezin izan da bidali!\n\nMezua honako hau zen: "'+message+'"', settings.DEFAULT_FROM_EMAIL, ['*****@*****.**'])
Beispiel #5
0
def post_reply(request, slug, topic_id):

    quote = request.GET.get("quote", "")
    author = request.GET.get("author", "")
    if quote:
        quote = "<blockquote>" + quote + "<footer>" + author + "</footer></blockquote>"

    forum = get_object_or_404(Forum, slug=slug)
    posts = Post.objects.filter(topic=topic_id).order_by("created").reverse()[:3]
    topic = Topic.objects.get(pk=topic_id)

    form_title = ""
    if topic.last_post():
        form_title = "Re: " + topic.last_post().title.replace("Re: ", "")

    default_data = {"title": form_title, "body": "Zure erantzuna..."}
    form = PostForm(default_data)

    if request.method == "POST":
        quote = request.POST.get("quote", "")
        form = PostForm(request.POST)

        if form.is_valid():

            post = Post()
            post.topic = topic
            post.title = form.cleaned_data["title"]
            post.body = quote + form.cleaned_data["body"]
            post.creator = request.user
            post.user_ip = request.META["REMOTE_ADDR"]

            post.save()

            l = Log()
            l.mota = "Foroa"
            l.tituloa = "Erantzun berria"
            l.deskripzioa = topic
            l.user = request.user
            l.post_id = post.id
            l.forum_id = forum.id
            l.save()

            return HttpResponseRedirect(reverse("topic-detail", args=(slug, topic.id)))

    return render_to_response(
        "django_simple_forum/reply.html",
        {"form": form, "topic": topic, "forum": forum, "posts": posts, "quote": quote},
        context_instance=RequestContext(request),
    )
Beispiel #6
0
def new_topic(request, slug):
    form = TopicForm()
    forum = get_object_or_404(Forum, slug=slug)

    if request.method == "POST":
        form = TopicForm(request.POST)

        if form.is_valid():

            topic = Topic()
            topic.title = form.cleaned_data["title"]
            topic.description = ""
            topic.creator = request.user
            topic.save()

            topic.forums.add(forum)
            topic.save()

            post = Post()
            post.title = form.cleaned_data["title"]
            post.body = form.cleaned_data["description"]
            post.creator = request.user
            post.user_ip = request.META["REMOTE_ADDR"]
            post.topic = topic
            post.save()

            l = Log()
            l.mota = "Foroa"
            l.tituloa = "Gai berria"
            l.deskripzioa = post.title
            l.post_id = post.id
            l.user = request.user
            l.forum_id = forum.id
            l.save()

            return HttpResponseRedirect(reverse("topic-detail", args=(slug, topic.id)))

    return render_to_response(
        "django_simple_forum/new-topic.html", {"form": form, "forum": forum}, context_instance=RequestContext(request)
    )