from django.http import HttpResponse, Http404, FileResponse
from django.conf import settings

def get_inter_Dict(user):

    from SubscribesApp.funcs import get_cur_user_subscribe
    user_subscribe = get_cur_user_subscribe(user)

    Dict = {
        'user_subscribe': user_subscribe,
    }
    from PushMessages.views import get_key_Dict
    Dict.update(get_key_Dict())

    return Dict

def get_inter_http_respose(template_obj, context_Dict, request):

    context_Dict.update(get_inter_Dict(request.user))

    from PushMessages.views import send_push
    if request and 'page' in context_Dict:
        text = None
        title = None

        if context_Dict['page'] == dict:
            if 'title' in context_Dict['page']:
                title = context_Dict['page']['title']
            if 'description' in context_Dict['page']:
                text = context_Dict['page']['description']
        else:
            title = getattr(context_Dict['page'], 'title', None)
            text = getattr(context_Dict['page'], 'description', None)

        if text and title and not request.user.is_anonymous:
            send_push(user=request.user, title=title, text=text)

    return HttpResponse(template_obj.render(context_Dict, request))