Commits

Anonymous committed 828341f

[svn r64] upload example.

  • Participants
  • Parent commits 5b6b9bd

Comments (0)

Files changed (17)

File djauthaupenid_example/__init__.py

Empty file added.

File djauthaupenid_example/manage.py

+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+    import settings # Assumed to be in the same directory.
+except ImportError:
+    import sys
+    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+    sys.exit(1)
+
+if __name__ == "__main__":
+    execute_manager(settings)

File djauthaupenid_example/settings.py

+# -*- coding: utf-8 -*-
+import os, platform
+
+PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+        ('Benoit Chesneau', 'bchesneau@gmail.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = 'sqlite3' 
+DATABASE_NAME = 'test.db'
+
+TIME_ZONE = 'Europe/Paris'
+
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+USE_I18N = True
+
+MEDIA_ROOT = ''
+
+MEDIA_URL = ''
+
+ADMIN_MEDIA_PREFIX = '/media/'
+
+ugettext = lambda s: s
+LOGIN_URL = '/%s%s' % (ugettext('account/'), ugettext('signin/'))
+
+SECRET_KEY = 'a1wyygkm7g&6u3xx47ohe&4yh^47w39wr0$73jq9_y*59-=mt&'
+
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.load_template_source',
+    'django.template.loaders.app_directories.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.common.CommonMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.middleware.doc.XViewMiddleware',
+)
+
+ROOT_URLCONF = 'djauthaupenid_example.urls'
+
+TEMPLATE_DIRS = (
+    os.path.join(PROJECT_PATH, 'templates'),
+)
+print os.path.join(PROJECT_PATH, 'templates')
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.admin',
+    'django_authopenid',
+)

File djauthaupenid_example/templates/authopenid/changeemail.html

+{% extends "base.html" %}
+{% load i18n %}
+
+
+
+
+{% block content %}
+<h4 class="headblue">{% trans "Account: change email" %}</h4>
+
+<p class="settings-descr">{% blocktrans %}This is where you can change the email address associated with your account. Please keep this email address up to date so we can send you a password-reset email if you request one.{% endblocktrans %}</p>
+{% if form.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+	{% if form.email.errors %} 
+		<span class="error">{{ form.email.errors|join:", " }}</span>
+	{% endif %}
+	{% if form.password.errors %} 
+		<span class="error">{{ form.password.errors|join:", " }}</span>
+	{% endif %}
+</p>
+{% endif %}
+{% if msg %}
+<p class="errors">{{ msg }}</p>
+{% endif %}
+
+
+<div class="aligned">
+	<form action="{{ path }}" method="post" accept-charset="utf-8">
+
+		<div id="form-row"><label for="id_email">{% trans "Email" %}</label>{{ form.email }}</div>
+		<div id="form-row"><label for="id_password">{% trans "Password" %}</label>{{ form.password }}</div>
+
+        <p><input type="submit" value="{% trans "Change email" %}"></p>
+
+	</form>
+	</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/changeopenid.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+<h4 class="headblue">{% trans "Account: change openid url" %}</h4>
+
+<p>{% blocktrans %}This is where you can change your openid url used to connect to friendsnippets. Make sure you remember it!{% endblocktrans %}</p>
+{% if form.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+	{% if form.openid_url.errors %} 
+		<span class="error">{{ form.openid_url.errors|join:", " }}</span>
+	{% endif %}
+
+
+</p>
+{% endif %}
+{% if msg %}
+	<p class="errors">{{ msg }}</p>
+{% endif %}
+
+<div class="aligned">
+	<form action="." method="post" accept-charset="utf-8">
+
+		<div id="form-row"><label for="id_openid_url">{% trans "OpenID url:" %}</label>{{ form.openid_url }}</div>
+        <p><input type="submit" value="{% trans "Change openid" %}"></p>
+
+	</form>
+	</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/changepw.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block head %}
+		
+{% endblock %}
+
+
+
+{% block content %}
+<h4 class="headblue">{% trans "Account: change password" %}</h4>
+
+<p>{% blocktrans %}This is where you can change your password. Make sure you remember it!{% endblocktrans %}</p>
+{% if form.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+{{ form.errors }}
+</p>
+{% endif %}
+
+<div class="aligned">
+	<form action="{{ path }}" method="post" accept-charset="utf-8">
+
+		<div id="form-row"><label for="id_oldpw">{% trans "Old password" %}</label>{{ form.oldpw }}</div>
+		<div id="form-row"><label for="id_password1">{% trans "New password" %}</label>{{ form.password1 }}</div>
+		<div id="form-row"><label for="id_password2">{% trans "New password again" %}</label>{{ form.password2 }}</div>
+        <p><input type="submit" value="{% trans "Change password" %}"></p>
+
+	</form>
+	</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/complete.html

+{% extends "base.html" %}
+{% load i18n %}
+
+
+
+{% block head %}{% endblock %}
+
+
+{% block content %}
+
+	<div id="completetxt">
+	<h1>{% trans "Your OpenID is verified! " %}</h1>
+	{% blocktrans %}
+	<p>Your OpenID can now be associated with a new or existing membership. You can change the association later in your preferences</p>
+	{% endblocktrans %}
+	<br /><br />
+	<h2>{% trans "Associate your OpenID" %}</h2>
+	{% blocktrans %}
+	<p>If you're joining <strong>Sitename</strong>, associate your OpenID with a new account. If you're already a member, associate with your existing account.</p>
+	{% endblocktrans %}
+	</div>
+
+		
+	
+	{% if form1.errors %}
+	<p class="errors">{% trans "Please correct errors below:" %}<br />
+		{% if form1.username.errors %} 
+			<span class="error">{{ form1.username.errors|join:", " }}</span>
+		{% endif %}
+		{% if form1.email.errors %} 
+			<span class="error">{{ form1.email.errors|join:", " }}</span>
+		{% endif %}
+	</p>
+	{% endif %}
+	{% if form2.errors %}
+	<p class="errors">{% trans "Please correct errors below:" %}<br />
+		{% if form2.username.errors %} 
+			<span class="error">{{ form2.username.errors|join:", " }}</span>
+		{% endif %}
+		{% if form2.password.errors %} 
+			<span class="error">{{ form2.password.errors|join:", " }}</span>
+		{% endif %}
+	</p>
+	{% endif %}
+
+	<div class="login">
+        <form name="fregister" action="{{ action }}" method="POST">
+            {{ form.next }}
+			<fieldset>
+				<legend>{% trans "A new account" %}</legend>
+				<div class="form-row"><label for "id_username">{% trans "Screen name" %}</label><br />{{ form1.username }}</div>
+				<div class="form-row"><label for "id_email">{% trans "Email" %}</label><br />{{ form1.email }}</div>
+				<div class="submit-row"><input type="submit" name="bnewaccount" value="CREATE MY ACCOUNT"></div>
+				<hr class="clear" />
+            	</fieldset>
+		</form>
+	</div>
+
+	
+
+	<div class="login">
+		<h3></h3>
+        <form name="fverify" action="{{ action }}" method="POST">
+            {{ form.next }}
+			<fieldset>
+				<legend>{% trans "An exisiting account" %}</legend>
+				<div class="form-row"><label for "id_username">{% trans "Screen name" %}</label><br />{{ form2.username }}</div>
+				<div class="form-row"><label for "id_passwordl">{% trans "Password" %}</label><br />{{ form2.password }}</div>
+				<div class="submit-row"><input type="submit" name="bverify" value="VERIFY"></div>
+			</fieldset>
+		</form>
+	</div>
+{% endblock %}
+
+	
+

File djauthaupenid_example/templates/authopenid/confirm_email.txt

+Thank you for registering. 
+
+Your account details are:
+
+Username: {{ username }}
+Password: {{ password }}
+
+
+You could sign in  with this url:
+{{ site_url }}signin/
+
+

File djauthaupenid_example/templates/authopenid/delete.html

+{% extends "base.html" %}
+{% load i18n %}
+
+
+{% block content %}
+<h4 class="headblue">{% trans "Account: delete account" %}</h4>
+
+<p class="settings-descr">{% blocktrans %}Note: After deleting your account, anyone will be able to register this username.{% endblocktrans %}</p>
+{% if form.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+	{% if form.confirm.errors %} 
+    <span class="error">{% trans "Check confirm box, if you want delete your account." %}</span><br />
+	{% endif %}
+	{% if form.password.errors %} 
+    <span class="error">{% trans "Password:" %} {{ form.password.errors|join:", " }}</span>
+	{% endif %}
+</p>
+{% endif %}
+{% if msg %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+    <span class="error">{{ msg }}</span>
+    </p>
+{% endif %}
+<div class="aligned">
+	<form action="." method="post" accept-charset="utf-8">
+
+        <div id="form-row"> {{ form.confirm }} {% trans "I am sure I want to delete my account." %}</div>
+        <div id="form-row"><label for="id_password">{% trans "Password/ OpenID URL" %}</label>{{ form.password }} {% trans "(required for your security)" %}</div>
+
+        <p><input type="submit" value="{% trans "delete account forever" %}"></p>
+
+	</form>
+	</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/failure.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+  "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+  <title>OpenID failed</title>
+</head>
+<body>
+<h1>OpenID failed</h1>
+
+<p>{{ message|escape }}</p>
+
+</body>
+</html>

File djauthaupenid_example/templates/authopenid/sendpw.html

+
+{% extends "base.html" %}
+{% load i18n %}
+
+
+{% block content %}
+<h4 class="headblue">{% trans "Account: Send a new password" %}</h4>
+
+<p class="settings-descr">{% blocktrans %}Lost your password ? Here you can ask to reset your password. Enter the username you use  and you will get a confirm mail with your new password. This new password will be activated only after you clicked on the link you will find in the email{% endblocktrans %}</p>
+{% if form.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+	{% if form.username.errors %} 
+		<span class="error">{{ form.username.errors|join:", " }}</span>
+	{% endif %}
+</p>
+{% endif %}
+{% if msg %}
+<br /
+<span class="error">{{ msg }}</span>
+{% endif %}
+
+<div class="aligned">
+	<form action="." method="post" accept-charset="utf-8">
+		<div id="form-row"><label for="id_username">{% trans "Username" %}</label>{{ form.username }}</div>
+
+        <p><input type="submit" value="{% trans "Send new password" %}"></p>
+
+	</form>
+	</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/sendpw_email.txt

+Someone ask to reset your password on {{ site_url }}. 
+If it's not you, please ignore this email. 
+
+Your new account details are:
+
+Username: {{ username }}
+New password: {{ password }}
+
+To confirm reset of your password go on this url:
+{{ site_url }}{{ url_confirm }}?key={{ confirm_key }}
+
+See you,
+

File djauthaupenid_example/templates/authopenid/settings.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block head %}
+<style type="text/css" media="screen">
+	dt, dd { padding:0 0 0.35em 0; }
+	dt { float: left; width: 21ex;  }
+	dd { margin-left: 23ex;  }
+	
+	#settings-options, #settings-intro { padding: 4em 1.5em;}
+	#settings-options { min-height: 300px; border-left: 1px solid #333;}
+	
+	#settings-options h5 { font-weight: bold;}
+</style>
+{% endblock %}
+
+{% block content %}
+<div id="settings-intro">
+	
+
+
+    <h4><strong>{{ user.username }}</strong> {% trans "Settings" %}</h4>
+    {% blocktrans %}
+    <p>This is where you can make changes to your account.</p>
+
+    {% endblocktrans %}
+</div>
+
+<div id="settings-options">
+	{% if msg %}
+		<p class="error">{{ msg }}</p>
+	{% endif %}
+    <h5>{% trans "Account" %}</h5>
+	<dl>
+        <dt>» <a href="{{ settings_path }}{% trans "password/" %}">{% trans "change password" %}</a></dt>
+        <dd>{% trans "Give your  account a new password." %}</dd>
+        <dt>» <a href="{{ settings_path }}{% trans "email/" %}">{% trans "change email" %}</a></dt>
+        <dd>{% trans "Add or update the email address associated with your account." %}</dd>
+        {% if is_openid %}
+        <dt>» <a href="{{ settings_path }}{% trans "openid/" %}">{% trans "change openid url" %}</a></dt>
+        <dd>{% trans "Change openid associated to your account" %}</dd>
+        {% endif %}
+        
+        <dt>» <a href="{{ settings_path }}{% trans "delete/" %}">{% trans "delete account" %}</a></dt>
+        <dd>{% trans "Erase your username and all your data from website" %}</dd>
+	</dl>
+</div>
+{% endblock %}

File djauthaupenid_example/templates/authopenid/signin.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block head %}
+
+
+{% endblock %}
+
+
+{% block content %}
+{% if msg %}
+<br />
+	<p class="warning">{{ msg }}</p>
+{% endif %}
+{% if form1.errors %}
+<p class="errors">{% trans "Please correct errors below:" %}<br />
+	{% if form1.username.errors %} 
+		<span class="error">{{ form1.username.errors|join:", " }}</span>
+	{% endif %}
+	{% if form1.password.errors %} 
+		<span class="error">{{ form1.password.errors|join:", " }}</span>
+	{% endif %}
+</p>
+{% endif %}
+<div class="login">
+
+    <form name="fauth" action="{{ action }}" method="post">
+        {{ form1.next }}
+	<fieldset>
+		<legend>{% trans "Sign In Using Your Account ID" %}</legend>
+		<div class="form-row"><label for="id_username">{% trans "Username:" %}</label><br />{{ form1.username }}</div>
+		<div class="form-row"><label for="id_password">{% trans "Password" %}</label><br />{{ form1.password }}</div>
+        <div class="submit-row"><input type="submit" name="blogin" value="{% trans "Sign in" %}"> </div>
+        <div>&nbsp;&nbsp;<a href="{{ sendpw_url }}">{% trans "Lost your password ?" %}</a></div>
+	</fieldset>	
+</form>
+
+<br />
+<form name="fopenid" action="{{ action }}" method="post">
+    {{ form2.next }}
+	<fieldset>
+		<legend>{% trans "Sign In Using Your OpenID" %}</legend>
+        <div class="form-row"><label for="id_openid_ul">{% trans "OpenId URL :" %}</label><br />{{ form2.openid_url }}</div>
+        <div class="submit-row "><input name="bsignin" type="submit" value="{% trans "Sign in with OPENID" %}"></div>
+		
+	</fieldset>
+</form>	
+</div>	
+{% endblock %}
+

File djauthaupenid_example/templates/authopenid/signup.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+<div class="jointxt">
+    {% blocktrans %}
+    <h1>Join</h1>
+    <p>There are two ways to join: with an email + screen name, or with OpenID.<br />Enter information only for the type of sign up you want to do.</p>
+    {% endblocktrans %}
+	<br />
+	<br />
+    <h2 class="signup">{% trans "Regular Signup" %}</h2>
+    {% if form.errors %}
+    <p class="errors">{% trans "Please correct errors below:" %}<br />
+    {% if form.username.errors %} 
+    <span class="error">{{ form.username.errors|join:", " }}</span>
+    {% endif %}
+    {% if form.email.errors %} 
+    <span class="error">{{ form.email.errors|join:", " }}</span>
+    {% endif %}
+    {% if form.password2.errors %} 
+    <span class="error">{{ form.password2.errors|join:", " }}</span>
+    {% endif %}
+    </p>
+    {% endif %}
+</div>
+    <form action="{{ action }}" method="post" accept-charset="utf-8">	
+        <div class="form-row"><label for="id_username">{% trans "Choose a Screen Name:" %}</label><br />{{ form.username }}</div>
+
+        <div class="form-row"><label for="id_email">{% trans "Enter Your Email Address:" %}</label><br />{{ form.email }}</div>
+        <div class="form-row"><label for="id_password1">{% trans "Choose a Password:" %}</label><br />{{ form.password1 }}</div>
+        <div class="form-row"><label for="id_password2">{% trans "Confirm Your Password:" %}</label><br />{{ form.password2 }}</div>
+
+        <div class="submit-row"><input type="submit" value="{% trans "JOIN FREE" %}" /></div>
+        <br />
+    </form>
+<br />
+    <h2 class="signup">{% trans "OpenID Signup" %}</h2>
+    <form name="fopenid" action="{{ action_signin }}" method="post">
+        <div class="form-row">{{ form2.openid_url }}</div>
+        <div class="submit-row "><input name="bsignin" type="submit" value="{% trans "Sign in with OPENID" %}"></div>
+    </form>
+{% endblock %}

File djauthaupenid_example/templates/base.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
+"http://www.w3.org/TR/html4/strict.dtd">
+{% load i18n %}
+
+<html lang="en">
+    <head>
+        <title>django_authopenid example </title>
+
+        <meta http-equiv="content-type" content="text/html; charset=utf-8">
+
+        {% block head %}
+        {% endblock %}
+    </head>
+    <body>
+        {% block content %}{% endblock %}
+
+    </body>
+</html>

File djauthaupenid_example/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+    (r'^account/', include('django_authopenid.urls')),
+    (r'^admin/', include('django.contrib.admin.urls')),
+)