Пример #1
0
def new_theme(request):
    """Create a new theme, using the client.html template as the default. """
    context = {}
    theme_form = None
    if request.method == "POST":
        # Validate and save the theme
        theme_form = ThemeForm(request.POST)
        if theme_form.is_valid():
            name = theme_form.cleaned_data["name"]
            content = theme_form.cleaned_data["content"]
            owner = request.user
            theme = Theme(name=name, content=content, owner=owner)
            theme.save()
            # Return edit theme template on successful
            # theme creation
            context["message"] = "Successfully Created Theme."
            context["form"] = theme_form

            return_response = render_response(request, "edittheme.html", context)
        else:
            context["form"] = theme_form
            return_response = render_response(request, "newtheme.html", context)

    else:
        # set initial context as client.html
        rendered = render_to_string("client.html", {})
        theme_form = ThemeForm(initial={"content": rendered})
        context["form"] = theme_form
        return_response = render_response(request, "newtheme.html", context)
    return return_response
Пример #2
0
def login(request):

    redirect_to = request.REQUEST.get('next', '/')
    redirect_to = redirect_to.replace("%3A", ":")
    errors = {}
    ret_response = None
    ret_str = None
    pcjid = None
    pcresource = None

    if request.method == "POST":

        errors = xmpp_auth(request)

        #authenticate to django and update user object
        if not errors:
            try:
                create_django_session(request)

                ret_response = HttpResponseRedirect(redirect_to)

            except Exception, ex:
                errors['username'] = ['Error with username or password. ']
                ret_response = render_response(request,
                                               'registration/login.html', {
                                                   'errors': errors,
                                                   'next': redirect_to
                                               })
        else:
            ret_response = render_response(request, 'registration/login.html',
                                           {
                                               'errors': errors,
                                               'next': redirect_to
                                           })
Пример #3
0
def join(request):
    """create a speeqe account"""
    context = {}
    if request.method == "POST":
        #create a register form to handle validation and errors
        register_form = RegisterForm(request.POST)
        context = {'form': register_form}
        if register_form.is_valid():
            #create the account
            new_member = register_form.save()

            username = new_member.username + "@" + new_member.realm
            user = auth.authenticate(username=username,
                                     password=new_member.password)
            request.session['user_password'] = register_form.cleaned_data[
                'password']
            if user is not None:
                auth.login(request, user)

                ret_response = render_response(request, 'index.html', context)
            else:
                context['message'] = "Error authenticating user"
                ret_response = render_response(request,
                                               'registration/join.html',
                                               context)
        else:
            context['message'] = "Error creating account."
            context['form'] = register_form
            ret_response = render_response(request, 'registration/join.html',
                                           context)
    else:
        ret_response = render_response(request, 'registration/join.html',
                                       context)
    return ret_response
Пример #4
0
def join(request):

    """create a speeqe account"""
    context = {}
    if request.method == "POST":
        # create a register form to handle validation and errors
        register_form = RegisterForm(request.POST)
        context = {"form": register_form}
        if register_form.is_valid():
            # create the account
            new_member = register_form.save()

            username = new_member.username + "@" + new_member.realm
            user = auth.authenticate(username=username, password=new_member.password)
            request.session["user_password"] = register_form.cleaned_data["password"]
            if user is not None:
                auth.login(request, user)

                ret_response = render_response(request, "index.html", context)
            else:
                context["message"] = "Error authenticating user"
                ret_response = render_response(request, "registration/join.html", context)
        else:
            context["message"] = "Error creating account."
            context["form"] = register_form
            ret_response = render_response(request, "registration/join.html", context)
    else:
        ret_response = render_response(request, "registration/join.html", context)
    return ret_response
Пример #5
0
def login(request):
	
	redirect_to = request.REQUEST.get('next', '/')
	redirect_to = redirect_to.replace("%3A",":")
	errors = {}
	ret_response = None
	ret_str = None
	pcjid = None
	pcresource = None

	if request.method == "POST":
		
		errors = xmpp_auth(request)
		
		#authenticate to django and update user object
		if not errors:
			try:
				create_django_session(request)
				
				ret_response = HttpResponseRedirect(redirect_to)
				
			except Exception, ex:
				errors['username'] = ['Error with username or password. ']
				ret_response = render_response(request,
							       'registration/login.html',
							       {'errors': errors,
								'next': redirect_to})				
		else:
			ret_response = render_response(request,
						       'registration/login.html',
						       {'errors': errors,
							'next': redirect_to})
Пример #6
0
def new_theme(request):
    """Create a new theme, using the client.html template as the default. """
    context = {}
    theme_form = None
    if request.method == "POST":
        #Validate and save the theme
        theme_form = ThemeForm(request.POST)
        if theme_form.is_valid():
            name = theme_form.cleaned_data['name']
            content = theme_form.cleaned_data['content']
            owner = request.user
            theme = Theme(name=name, content=content, owner=owner)
            theme.save()
            #Return edit theme template on successful
            #theme creation
            context['message'] = "Successfully Created Theme."
            context['form'] = theme_form

            return_response = render_response(request, 'edittheme.html',
                                              context)
        else:
            context['form'] = theme_form
            return_response = render_response(request, 'newtheme.html',
                                              context)

    else:
        #set initial context as client.html
        rendered = render_to_string('client.html', {})
        theme_form = ThemeForm(initial={'content': rendered})
        context['form'] = theme_form
        return_response = render_response(request, 'newtheme.html', context)
    return return_response
Пример #7
0
def jqtouch(request,room_name=None,theme_name=None):

	#included to solve errors about an undefined global name "room"
#	room = room_name
#	if not room:
#		#default room is speeqers
#		room = request.GET.get('room',"speeqers")
#		
#	if not theme_name:
#		theme = request.GET.get('theme',room)
#	else:
#		theme = request.GET.get('theme',theme_name)


	#detect iphone and force use of iphone theme
	user_agent = request.META.get('HTTP_USER_AGENT','')
	if (user_agent.lower().find("ipod") != -1) or \
	       (user_agent.lower().find("iphone") != -1) or \
	       (user_agent.lower().find("android") != -1):
		theme = "iphone"
		
	home_theme = "index_jqtouch.html"
	try:
		home_theme = get_template("themes/"+theme+"_home.html")
	except:
		home_theme = get_template("desktop_home.html")

	context = {'home_theme': home_theme}

	index_template = "index_jqtouch.html"
	
	if request.user.is_anonymous():
		request.session.set_test_cookie()
	
	return render_response(request, index_template,context)
Пример #8
0
def list_themes(request):
	"""List a user's themes. """


	themes = Theme.objects.filter(owner=request.user)
	
	return render_response(request,
			       'listthemes.html',
			       {'themes':themes})
Пример #9
0
def index(request):
    context = {}

    index_template = "index.html"

    if request.user.is_anonymous():
        request.session.set_test_cookie()

    return render_response(request, index_template, context)
Пример #10
0
def index(request):
	context = {}

	index_template = "index.html"
	
	if request.user.is_anonymous():
		request.session.set_test_cookie()
	
	return render_response(request, index_template,context)
Пример #11
0
def featured(request):

	context = {'home_theme': 'test'}

	index_template = "featured.html"

	if request.user.is_anonymous():
		request.session.set_test_cookie()
	
	return render_response(request,index_template,context)
Пример #12
0
def client(request, room_name=None, virtual_name=None, theme_name=None):
    """Start up the chat client with the requested room """
    room = room_name
    if not room:
        #default room is speeqers
        room = request.GET.get('room', "speeqers")
    if virtual_name:
        room = virtual_name.replace("." + settings.HTTP_DOMAIN, "")

    if not theme_name:
        theme = request.GET.get('theme', room)
    else:
        theme = request.GET.get('theme', theme_name)

    #detect iphone and force use of iphone theme
    user_agent = request.META.get('HTTP_USER_AGENT', '')
    if (user_agent.lower().find("ipod") != -1) or \
           (user_agent.lower().find("iphone") != -1):
        theme = "iphone"

    userpassword = None
    pcjid = None
    pcresource = None
    fullusername = request.user.username
    ip_address = request.META.get('HTTP_X_FORWARDED_FOR',
                                  request.META.get('REMOTE_ADDR',
                                                   '')).split(', ')[-1]
    if not 'nologin' in request.GET and request.user.is_authenticated():

        userpassword = request.session.get('user_password', None)

        if 'cred' in request.GET and userpassword:

            resp = HttpResponse(userpassword)
            resp['Expires'] = datetime.datetime.now().strftime(
                '%a, %d %b %Y %T GMT')
            return resp
    room_theme = "client.html"
    try:

        room_theme = get_template("themes/" + theme + "_client.html")
    except:
        room_theme = get_template("client.html")

    return render_response(
        request, 'autologinclient.html', {
            'username': fullusername,
            'userpassword': userpassword,
            'pcjid': pcjid,
            'pcresource': pcresource,
            'ip_address': ip_address,
            'room': room,
            'theme': theme,
            'room_theme': room_theme
        })
Пример #13
0
def room_message_search(request, room=None):
    """Search rooms for chat history. """
    if not room:
        room = request.GET.get("room", None)
    user = request.GET.get("user", None)
    q = request.GET.get("q", None)
    message_type = request.GET.get("message_type", 3)
    start_date = request.GET.get("start_date", None)
    end_date = request.GET.get("end_date", None)

    return render_response(request, "messagesearch.html", {"room": room})
Пример #14
0
def room_message_search(request, room=None):
    """Search rooms for chat history. """
    if not room:
        room = request.GET.get('room', None)
    user = request.GET.get('user', None)
    q = request.GET.get('q', None)
    message_type = request.GET.get('message_type', 3)
    start_date = request.GET.get('start_date', None)
    end_date = request.GET.get('end_date', None)

    return render_response(request, 'messagesearch.html', {'room': room})
Пример #15
0
def client(request, room_name=None, virtual_name=None, theme_name=None):
    """Start up the chat client with the requested room """
    room = room_name
    if not room:
        # default room is speeqers
        room = request.GET.get("room", "speeqers")
    if virtual_name:
        room = virtual_name.replace("." + settings.HTTP_DOMAIN, "")

    if not theme_name:
        theme = request.GET.get("theme", room)
    else:
        theme = request.GET.get("theme", theme_name)

        # detect iphone and force use of iphone theme
    user_agent = request.META.get("HTTP_USER_AGENT", "")
    if (user_agent.lower().find("ipod") != -1) or (user_agent.lower().find("iphone") != -1):
        theme = "iphone"

    userpassword = None
    pcjid = None
    pcresource = None
    fullusername = request.user.username
    ip_address = request.META.get("HTTP_X_FORWARDED_FOR", request.META.get("REMOTE_ADDR", "")).split(", ")[-1]
    if not "nologin" in request.GET and request.user.is_authenticated():

        userpassword = request.session.get("user_password", None)

        if "cred" in request.GET and userpassword:

            resp = HttpResponse(userpassword)
            resp["Expires"] = datetime.datetime.now().strftime("%a, %d %b %Y %T GMT")
            return resp
    room_theme = "client.html"
    try:

        room_theme = get_template("themes/" + theme + "_client.html")
    except:
        room_theme = get_template("client.html")

    return render_response(
        request,
        "autologinclient.html",
        {
            "username": fullusername,
            "userpassword": userpassword,
            "pcjid": pcjid,
            "pcresource": pcresource,
            "ip_address": ip_address,
            "room": room,
            "theme": theme,
            "room_theme": room_theme,
        },
    )
Пример #16
0
def debugging(request,room_name=None,theme_name=None):
	"""Start up the chat client with the requested room """
	room = room_name
	if not room:
		#default room is speeqers
		room = request.GET.get('room',"speeqers")
		
	if not theme_name:
		theme = request.GET.get('theme',room)
	else:
		theme = request.GET.get('theme',theme_name)


	#detect iphone and force use of iphone theme
	user_agent = request.META.get('HTTP_USER_AGENT','')
	if (user_agent.lower().find("ipod") != -1) or \
	       (user_agent.lower().find("iphone") != -1) or \
	       (user_agent.lower().find("android") != -1):
		theme = "iphone"
	
	userpassword = None
	pcjid = None
	pcresource = None
	fullusername = request.user.username
	ip_address = request.META.get('HTTP_X_FORWARDED_FOR',
				      request.META.get('REMOTE_ADDR', '')).split(', ')[-1]
	if not 'nologin' in request.GET and request.user.is_authenticated(): 

		userpassword = request.session.get('user_password',None)
		
		if 'cred' in request.GET and userpassword:
			
			resp = HttpResponse(userpassword)
			resp['Expires'] = datetime.datetime.now().strftime('%a, %d %b %Y %T GMT')
			return resp
	room_theme = "client.html"
	try:
	
		room_theme = get_template("themes/"+theme+"_client.html")
	except:
		room_theme = get_template("client.html")
	
	return render_response(request,
			       'debugging.html',
			       {'username': fullusername,
				'userpassword': userpassword,
				'pcjid':pcjid,
				'pcresource':pcresource,
				'ip_address': ip_address,
				'room':room,
				'theme':theme,
				'room_theme':room_theme})
Пример #17
0
def confirm_email(request):
    """Confirm a users email with the generated code."""
    context = {}
    code = request.GET.get('url')
    try:
        email_confirmation = EmailConfirmation.objects.get(code=code)
        email_confirmation.confirmed = True
        email_confirmation.save()
        context['message'] = "Email confirmed."
    except EmailConfirmation.DoesNotExist:
        context['message'] = "Unknown code."

    return render_response(request, 'confirmemail.html', context)
Пример #18
0
def confirm_email(request):
    """Confirm a users email with the generated code."""
    context = {}
    code = request.GET.get("url")
    try:
        email_confirmation = EmailConfirmation.objects.get(code=code)
        email_confirmation.confirmed = True
        email_confirmation.save()
        context["message"] = "Email confirmed."
    except EmailConfirmation.DoesNotExist:
        context["message"] = "Unknown code."

    return render_response(request, "confirmemail.html", context)
Пример #19
0
def room_message_search(request,room=None):
	"""Search rooms for chat history. """
	if not room:
		room = request.GET.get('room',None)
	user = request.GET.get('user',None)
	q = request.GET.get('q',None)
	message_type = request.GET.get('message_type',3)
	start_date = request.GET.get('start_date',None)
	end_date = request.GET.get('end_date',None)
	
	
	return render_response(request,
			       'messagesearch.html',
			       {'room':room})
Пример #20
0
def categories(request):
	if 'lat' in request.GET and request.GET['lat']:
		lat = request.GET['lat']
		lon = request.GET['lon']
		commaseparator = ","
		latlon = str(lat) + commaseparator + str(lon)
		import simplegeo
		client = simplegeo.Client('mNCDKS3NUaupW7pA2gYAKfQBaJB2MaR6', 'nL2Mck79PUGZX8yZYGgxCdLKRC7E5w6n')
		result_raw = client.get_nearby('com.simplegeo.global.geonames', latlon, limit=10, radius=0.5)
		result = simplejson.dumps(result_raw)
		return render_response(request,
			'simplegeo2.html',
			{'result': result})
	else:
		return HttpResponse('Please submit a search term.')
Пример #21
0
def edit_theme(request, theme_id=None):

    context = {}
    theme = get_object_or_404(Theme, id=theme_id)
    if request.method == "POST":
        #Validate and save the theme
        theme_form = ThemeForm(request.POST)
        if theme_form.is_valid():
            theme.name = theme_form.cleaned_data['name']
            theme.content = theme_form.cleaned_data['content']
            theme.owner = request.user
            theme.save()

        context['form'] = theme_form
    else:
        theme_form = ThemeForm({'name': theme.name, 'content': theme.content})
        context['form'] = theme_form

    return render_response(request, 'edittheme.html', context)
Пример #22
0
def edit_theme(request, theme_id=None):

    context = {}
    theme = get_object_or_404(Theme, id=theme_id)
    if request.method == "POST":
        # Validate and save the theme
        theme_form = ThemeForm(request.POST)
        if theme_form.is_valid():
            theme.name = theme_form.cleaned_data["name"]
            theme.content = theme_form.cleaned_data["content"]
            theme.owner = request.user
            theme.save()

        context["form"] = theme_form
    else:
        theme_form = ThemeForm({"name": theme.name, "content": theme.content})
        context["form"] = theme_form

    return render_response(request, "edittheme.html", context)
Пример #23
0
def edit_theme(request,theme_id=None):
	
	context = {}
	theme = get_object_or_404(Theme,id=theme_id)
	if request.method == "POST":
		#Validate and save the theme
		theme_form = ThemeForm(request.POST)
		if theme_form.is_valid():			
			theme.name=theme_form.cleaned_data['name']
			theme.content=theme_form.cleaned_data['content']
			theme.owner=request.user
			theme.save()

		context['form'] = theme_form
	else:
		theme_form = ThemeForm({'name':theme.name,
				       'content':theme.content})
		context['form'] = theme_form
		
	return render_response(request,
			       'edittheme.html',
			       context)
Пример #24
0
def place_page(request, placename):
	
	"""From Client Class, used to check-in """
	room = placename
	theme = "iphone"
	
	userpassword = None
	pcjid = None
	pcresource = None
	fullusername = request.user.username
	ip_address = request.META.get('HTTP_X_FORWARDED_FOR',
				      request.META.get('REMOTE_ADDR', '')).split(', ')[-1]

	if not 'nologin' in request.GET and request.user.is_authenticated(): 
		userpassword = request.session.get('user_password',None)
		
		if 'cred' in request.GET and userpassword:			
			resp = HttpResponse(userpassword)
			resp['Expires'] = datetime.datetime.now().strftime('%a, %d %b %Y %T GMT')
			return resp

	"""Original place_page Class, some duplicate code, should be cleaned up """
	if request.user.is_authenticated():
		auth_name = request.user.username
	else:
		auth_name = 'Not Authenticated'

	return render_response(request,
			       'place_page.html',
			       {'username': fullusername,
				'userpassword': userpassword,
				'pcjid':pcjid,
				'pcresource':pcresource,
				'ip_address': ip_address,
				'room':room,
				'theme':theme,
				'auth_name': auth_name,
				'placename': placename})
Пример #25
0
def index(request):

	#detect mobile devices and force use of mobile theme
	user_agent = request.META.get('HTTP_USER_AGENT','')
	if (user_agent.lower().find("ipod") != -1) or \
	       (user_agent.lower().find("iphone") != -1) or \
	       (user_agent.lower().find("android") != -1):
		theme = "iphone"
		
	home_theme = "index_web.html"
	try:
		home_theme = get_template("themes/index_"+theme+".html")
	except:
		home_theme = get_template("index_web.html")

	context = {'home_theme': home_theme}

	index_template = "index.html"
	
	if request.user.is_anonymous():
		request.session.set_test_cookie()
	
	return render_response(request,index_template,context)
Пример #26
0
                ret_response = render_response(request,
                                               'registration/login.html', {
                                                   'errors': errors,
                                                   'next': redirect_to
                                               })
        else:
            ret_response = render_response(request, 'registration/login.html',
                                           {
                                               'errors': errors,
                                               'next': redirect_to
                                           })
    else:

        request.session.set_test_cookie()
        ret_response = render_response(request, 'registration/login.html', {
            'errors': errors,
            'next': redirect_to
        })
    return ret_response


def client(request, room_name=None, virtual_name=None, theme_name=None):
    """Start up the chat client with the requested room """
    room = room_name
    if not room:
        #default room is speeqers
        room = request.GET.get('room', "speeqers")
    if virtual_name:
        room = virtual_name.replace("." + settings.HTTP_DOMAIN, "")

    if not theme_name:
        theme = request.GET.get('theme', room)
Пример #27
0
def list_themes(request):
    """List a user's themes. """

    themes = Theme.objects.filter(owner=request.user)

    return render_response(request, 'listthemes.html', {'themes': themes})
Пример #28
0
            try:
                create_django_session(request)

                ret_response = HttpResponseRedirect(redirect_to)

            except Exception, ex:
                errors["username"] = ["Error with username or password. "]
                ret_response = render_response(
                    request, "registration/login.html", {"errors": errors, "next": redirect_to}
                )
        else:
            ret_response = render_response(request, "registration/login.html", {"errors": errors, "next": redirect_to})
    else:

        request.session.set_test_cookie()
        ret_response = render_response(request, "registration/login.html", {"errors": errors, "next": redirect_to})
    return ret_response


def client(request, room_name=None, virtual_name=None, theme_name=None):
    """Start up the chat client with the requested room """
    room = room_name
    if not room:
        # default room is speeqers
        room = request.GET.get("room", "speeqers")
    if virtual_name:
        room = virtual_name.replace("." + settings.HTTP_DOMAIN, "")

    if not theme_name:
        theme = request.GET.get("theme", room)
    else:
Пример #29
0
#							       'registration/login_test.html',
							       'themes/login_iphone.html',
							       {'errors': errors,
								'next': redirect_to})				
		else:
			ret_response = render_response(request,
#						       'registration/login_test.html',
							'themes/login_iphone.html',
						       {'errors': errors,
							'next': redirect_to})
	else:
		
		request.session.set_test_cookie()
		ret_response = render_response(request,
#					     'registration/login_test.html',
					     'themes/login_iphone.html',
					     {'errors': errors,
					      'next': redirect_to})
	return ret_response


# IL: added for ajaxy logout
def logout2(request, template_name='registration/skipola/logged_out.html'):
    "Logs out the user and displays 'You are logged out' message."
    from django.contrib.auth import logout
    logout(request)
    return render_response(request, template_name)


# IL: added for ajaxy password change
def password_change_done2(request, template_name='registration/skipola/password_change_done.html'):
Пример #30
0
def logout2(request, template_name='registration/skipola/logged_out.html'):
    "Logs out the user and displays 'You are logged out' message."
    from django.contrib.auth import logout
    logout(request)
    return render_response(request, template_name)
Пример #31
0
			except Exception, ex:
				errors['username'] = ['Error with username or password. ']
				ret_response = render_response(request,
							       'registration/login.html',
							       {'errors': errors,
								'next': redirect_to})				
		else:
			ret_response = render_response(request,
						       'registration/login.html',
						       {'errors': errors,
							'next': redirect_to})
	else:
		
		request.session.set_test_cookie()
		ret_response = render_response(request,
					     'registration/login.html',
					     {'errors': errors,
					      'next': redirect_to})
	return ret_response

def client(request,room_name,theme_name=None):
	"""new code looking up verified places"""
	placename = room_name
	room_name=None
	place = Place.objects.filter(
	    geoapi_guid=placename
	)
	if place:
	    places = 'success'
	else:
	    places = ''
	"""end new code"""