from django.shortcuts import render
#added
from machina import MACHINA_MAIN_STATIC_DIR

# Create your views here.

#from django.views.generic import CreateView
# Create your views here.

def load_view(self, *args, **kwargs):
    print ('LOAD_VIEW')
    print ('self')
    print(self)

    request = self

    print('args')
    print(args)

    print('kwargs')
    print(kwargs)
    #print(self.request)
    print('request')
    #print ('BACK TO REGULAR URL')
    print(request) #<WSGIRequest: GET '/terms/'>
    print(request.get_full_path())
    #print(request2)
    request_path = request.get_full_path() # without the domain e.g. terms/


    request_path = request_path.lstrip( '/')
    request_path = request_path.rstrip('/')

    print(request_path + '.html')
    return render(request, request_path + '.html')
    #return render(request, 'index.html')

#in gun
def load_static(self, *args):
    request = self
    print('load_static')
    return render(request,MACHINA_MAIN_STATIC_DIR )


def index(self, *args):
    request = self
    return render(request, 'index.html')


class PageView:

    def __init__(request):
        #no actions yet.
        #if re_path(<slug>):
        print ('THE REQUEST CONSTRUCTOR')
        print (request)
        #print (self)
        return true



    def as_view(template_name):

        print ('the request asview')
        #print (self.request)
        print (template_name)
        #print(request)

        return render(request, 'index.html')

    def index(request):


        # Render the HTML template index.html with the data in the context variable
        return render(request, 'index.html')

    def terms(request):
        print('the request')
        print(request)
        return render(request,'terms.html')

    def privacy(request):
        return render (request,'privacy.html')
