from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
import os
from google.appengine.ext.webapp import template
from google.appengine.api import users
from gaesessions import get_current_session
import logging
import model
import urllib
from google.appengine.ext import db
import random
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext import blobstore
from os import environ
from google.appengine.api import memcache
from google.appengine.api import images
from google.appengine.api import oauth
import Cookie
import hashlib
from controllers.check_login import check_login
from controllers.show_error_html import show_error_html
from controllers.check_admin import check_admin
from google.appengine.api import users



def show_send_invite_form(self):
    logging.debug("show_send_invite_form")
    login_url = users.create_login_url("/?send_invite=True")
    user = users.get_current_user()
    if not user:
        self.response.out.write("<a href='%s'>Log in via google</a>" % login_url)
        return

        
    
    try:
        path = os.path.join(os.path.dirname(__file__))
        path_length = path.__len__()
        final_path = path[0:path_length-11] + 'views/htmls/show_send_invite_form.html'
        
        logging.debug("path = " + path)
        logging.debug("final_path = " + final_path)
        logged_in = check_login(self)
            
            
        data = {
            "logged_in": logged_in,
            "title_kind": "Welcome to our crowdsourcing site!",
        }
        
        self.response.out.write(template.render(final_path, data))         
    except:
        logging.debug("exception")
        show_error_html(self, "template error")