Cleaned/removed some unused code

- Legacy-Id: 1732
This commit is contained in:
Pasi Eronen 2009-10-16 10:13:54 +00:00
parent c6fa99c139
commit 8b6536f32e
11 changed files with 0 additions and 433 deletions

View file

@ -1,33 +0,0 @@
#!/usr/bin/env python
#
from django.core.exceptions import ObjectDoesNotExist
from ietf.ietfauth.models import LegacyLiaisonUser, LegacyWgPassword
from ietf.idtracker.models import IESGLogin
output = {}
# we use pseudo-polymorphism to get through all of these objects.
for p in list( IESGLogin.objects.all() ) + \
list( LegacyLiaisonUser.objects.all() ) + \
list( LegacyWgPassword.objects.all() ):
# Bad rows in these tables use bad references.
if p.person_id == 0 or p.person_id == 999999 or p.person_id == 888888:
continue
# Skip if we've already output this person
if p.login_name in output:
continue
output[ p.login_name ] = 1
if p.person.usermap_set.count() != 1:
print "# Can't find user mapping for %s" % p.login_name
continue
usermap = p.person.usermap_set.all()[0]
u = usermap.user
( algo, salt, hsh ) = u.password.split( '$' )
if algo != 'htdigest':
continue
if p.login_name == u.username:
print "%s:IETF:%s" % ( u.username, hsh )
elif p.login_name == u.email:
print "%s:IETF:%s" % ( u.email, usermap.email_htdigest )
else:
print "# Can't find user mapping for %s (%s/%s)" % ( p.login_name, u.username, u.email )

View file

@ -1,116 +0,0 @@
#!/usr/bin/env python
#
# Copyright The IETF Trust 2007, 2008, All Rights Reserved
#
# Import users from all different IETF authentication sources into
# django. Map user names to people via the ietf.ietfauth.models.UserMap
# model. Use the htpasswd file to get passwords, ignoring any password
# stored in the database.
#
# If the user already exists, just update their group memberships
# and/or privileges. This script can be run multiple times with no
# adverse effect.
#
# Note that there are a couple of people who have multiple accounts.
# This scheme will give them one single account, with all of the
# privilges of the original account.
#
# Data sources:
# - IESGLogin
# - LegacyWgPassword
# - Liaison tool ('Users')
# - Then look for email address
#
# The LegacyWgPassword table contains a plaintext password, which is
# both unconscionable and very useful, as it lets us upgrade their
# password to full htdigest style.
#
#
from ietf.idtracker.models import PersonOrOrgInfo, IESGLogin, EmailAddress
from ietf.ietfauth.models import LegacyWgPassword, LegacyLiaisonUser
from ietf.ietfauth.auth import set_password
from ietf.utils import users
from django.core.validators import email_re
from django.contrib.auth.models import Group
import sys
# Group mappings for IESGLogin entries
level2group = {
0: 'Secretariat',
1: 'IESG',
2: 'ex-IESG',
}
if len(sys.argv) != 2:
print "usage: import-users htpasswd"
sys.exit(1)
f = open(sys.argv[1], 'r')
line = f.readline()
while line != '':
(user, pw) = line.rstrip("\n").split(":")
person = None
wg = None
# Some login names are a different E-Mail
# address than the one stored in email_addresses.
# If the login name looks like an email address
# then use it.
if email_re.search(user):
email = user
else:
email = None
try:
iesg = IESGLogin.objects.get(login_name=user)
try:
person = iesg.person
except PersonOrOrgInfo.DoesNotExist:
iesg = None
except IESGLogin.DoesNotExist:
iesg = None
if person is None:
try:
wg = LegacyWgPassword.objects.get(login_name=user)
person = wg.person
except LegacyWgPassword.DoesNotExist:
pass
except AssertionError:
print "%s has multiple WGPassword rows, so couldn't pick" % user
if person is None:
try:
liaison = LegacyLiaisonUser.objects.get(login_name=user)
person = liaison.person
except LegacyLiaisonUser.DoesNotExist:
pass
if person is None and email:
try:
person = PersonOrOrgInfo.objects.distinct().get(emailaddress__address__iexact=user)
except PersonOrOrgInfo.DoesNotExist:
pass
except AssertionError:
print "%s has multiple PersonOrOrgInfo entries, so couldn't pick" % email
if person is not None:
try:
u = users.create_user(user, email, person, cryptpw=pw)
except users.UserAlreadyExists, (msg, u):
print "Already in system as %s when adding %s (%s)" % ( u.username, user, email )
if not email_re.search( user ):
# If the existing username looks like it's one we made up
# (first_last), then change it to the one in the digest file.
if "_" in u.username:
print "Changing username from %s to %s" % ( u.username, user )
u.username = user
u.save()
if iesg:
try:
group, created = Group.objects.get_or_create(name = level2group[iesg.user_level])
except KeyError:
group = None
if group:
print "Adding %s to %s (user_level %d)" % (u.username, group.name, iesg.user_level)
u.groups.add(group)
if wg and wg.password:
# Use the plaintext password
set_password( u, wg.password )
else:
print "Could not map %s to person" % ( user )
line = f.readline()

View file

@ -1,50 +0,0 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
{% extends "base.html" %}
{% block title %}IETF Announcement{% endblock %}
{% block head %}
<style type="text/css" media="all">@import "/css/base.css";</style>
{% endblock %}
{% block content %}
<div>
<form action="{% url ietf.announcements.views.send %}" method="post">
{% if form.is_valid %}{% ifequal request.POST.op "Preview" %}
<pre>
From: {{ form.clean_data.sender }}
To: {{ form.clean_data.recipient }}{% if form.clean_data.cc %}
Cc: {{ form.clean_data.cc }}{% endif %}{% if form.clean_data.bcc %}
Bcc: {{ form.clean_data.bcc }}{% endif %}{% if form.clean_data.reply_to %}
Reply-to: {{ form.clean_data.reply_to }}{% endif %}
{{ form.clean_data.body }}
</pre>
<input class="form-submit" name="op" type="submit" value="Send"/>
{% endifequal %}{% endif %}
{% for field in form %}
<div class="form-item">
{{ field.label_tag }}
{# Ideally this would go in the <lable> tag #}
{% if field.field.required %}
<span class="form-required" title="This field is required.">*</span>
{% endif %}
{{ field }}
{% if field.help_text %}
<div class="description">
{{ field.help_text }}
</div>
{% endif %}
{% if field.errors %}{{field.errors }}{% endif %}
</div>
{% endfor %}
<input class="form-submit" name="op" type="submit" value="Preview"/>
</form>
</div>
{% endblock %}

View file

@ -1,13 +0,0 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
{% extends "base.html" %}
{% block title %}IETF Announcement{% endblock %}
{% block head %}
<style type="text/css" media="all">@import "http://cvs.drupal.org/viewvc.py/drupal/drupal/modules/system/system.css?view=co";</style>
{% endblock %}
{% block content %}
<h2>Announcement sent.</h2>
{% endblock %}

View file

@ -1 +0,0 @@
/*.pyc

View file

@ -1,17 +0,0 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Review pages</title>
</head>
<body>
<h1>Review items</h1>
( There are {{ count }} items in the list )
<ul>
{% for item in info %}
<li><a href="/review/{{ item.num }}/">{{ item.old }}</a></li>
{% endfor %}
</ul>
</body>
</html>

View file

@ -1,22 +0,0 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Comparison -- {{ info.old }} - {{ info.new }}</title>
</head>
<frameset rows="70, *">
<frame src="/review/top/{{ info.this }}">
<frameset cols="50%, 50%">
<frame name="old" src="{{ info.old }}">
<frame name="new" src="{{ info.new }}">
</frameset>
<noframes>
<p>this frameset document contains:
<ul>
<li><a href="{{ info.old }}">The old page</a><li>
<li><a href="{{ info.new }}">The new page</a><li>
</ul>
</noframes>
</frameset>
</html>

View file

@ -1,24 +0,0 @@
{# Copyright The IETF Trust 2007, All Rights Reserved #}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Comparison - {{ info.old }} / {{ info.new }}</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td align="left" width="49%">
<a href="../../{{ info.prev }}" target="_top">&lt; Prev</a>
<br /><br />
<a href="{{ info.old }}" target="old">{{ info.old }}</a></td>
<td align="center" valign="top"><a href="/review/all/" target="_top">All</a></td>
<td align="right" width="49%">
<a href="../../{{ info.next }}" target="_top">Next &gt;</a>
<br /><br />
<a href="{{ info.new }}" target="new">{{ info.new }}</a></td>
</td>
</tr>
</table>
</body>
</html>

View file

@ -42,7 +42,6 @@ urlpatterns = patterns('',
{'sitemaps': sitemaps}),
(r'^ann/', include('ietf.announcements.urls')),
(r'^idtracker/', include('ietf.idtracker.urls')),
#(r'^my/', include('ietf.my.urls')),
(r'^drafts/', include('ietf.idindex.urls')),
(r'^iesg/', include('ietf.iesg.urls')),
(r'^liaison/', include('ietf.liaisons.urls')),
@ -56,21 +55,9 @@ urlpatterns = patterns('',
(r'^$', 'ietf.redirects.views.redirect'),
# Uncomment this for review pages:
#(r'^review/$', 'ietf.utils.views.review'),
#(r'^review/all/$', 'ietf.utils.views.all'),
#(r'^review/(?P<page>[0-9a-f]+)/$', 'ietf.utils.views.review'),
#(r'^review/top/(?P<page>[0-9a-f]+)/$', 'ietf.utils.views.top'),
# Google webmaster tools verification url
(r'^googlea30ad1dacffb5e5b.html', 'django.views.generic.simple.direct_to_template', { 'template': 'googlea30ad1dacffb5e5b.html' }),
# ekr, fluffy, wgcharter tool
# (r'^wgcharter/', include('ietf.wgcharter.urls')),
# Uncomment this for pre-approval tool for initial Internet-Drafts
#(r'^wg/', include('ietf.wg.urls')),
# Django 0.96 hardcodes /accounts/; we want to use
# /account/.
(r'^accounts/(?P<dir>\w+)/', 'django.views.generic.simple.redirect_to', { 'url': '/account/%(dir)s/' }),

View file

@ -1,83 +0,0 @@
# Copyright The IETF Trust 2007, All Rights Reserved
#
from ietf.ietfauth.models import UserMap
from ietf.ietfauth.auth import set_password
from django.contrib.auth.models import User
from django.template import defaultfilters
class UserAlreadyExists(Exception):
pass
def create_user(user, email, person, pw=None, cryptpw=None):
try:
umap = UserMap.objects.get(person = person)
u = umap.user
raise UserAlreadyExists("Already in system as %s when adding %s (%s)" % ( u.username, user, email ), u)
except UserMap.DoesNotExist:
pass
if user is None or '@' in user:
# slugify to remove non-ASCII; slugify uses hyphens but
# user schema says underscore.
user = defaultfilters.slugify(str(person)).replace("-", "_")
if email is None:
email = person.email()[1]
# Make sure the username is unique.
# If it already exists,
# 1. if the email is the same then skip, it's the same person
# 2. otherwise, add a number to the end of the username
# and loop.
add = ''
while True:
try:
t = user
if add:
t += "%d" % ( add )
u = User.objects.get(username__iexact = t)
except User.DoesNotExist:
u = None
user = t
break
if u.email == email:
break
else:
if add == '':
add = 2
else:
add = add + 1
if not u:
try:
map = UserMap.objects.get(person = person)
u = map.user
except UserMap.DoesNotExist:
pass
if u:
# Fill in the user's name from the IETF data
if u.first_name != person.first_name or u.last_name != person.last_name:
u.first_name = person.first_name
u.last_name = person.last_name
u.save()
# make sure that the UserMap gets created
umap, created = UserMap.objects.get_or_create(user = u,
defaults={'person': person})
if not created:
umap.person = person
umap.save()
raise UserAlreadyExists("Already in system as %s when adding %s (%s)" % ( u.username, user, email ), u)
else:
if cryptpw:
password = 'crypt$%s$%s' % ( cryptpw[:2], cryptpw[2:] )
else:
password = '!' # no hash
u = User(username = user, email = email, password = password, first_name = person.first_name, last_name = person.last_name )
if pw:
set_password(u, pw)
#print "Saving user: username='%s', email='%s'" % ( u.username, u.email )
u.save()
umap, created = UserMap.objects.get_or_create(user = u,
defaults={'person': person})
if not created:
umap.person = person
umap.save()
return u

View file

@ -1,61 +0,0 @@
# Copyright The IETF Trust 2007, All Rights Reserved
from django.shortcuts import render_to_response as render
testurls = []
urlcount = 0
hash2url = {}
num2hash = {}
hash2num = {}
host = "merlot.tools.ietf.org:31415"
def get_info(page):
global testurls
global hash2url
global num2hash
global hash2num
global urlcount
if not testurls:
from ietf.tests import get_testurls
testurls = [ tuple for tuple in get_testurls() if tuple[2] and "200" in tuple[0] ]
urlcount = len(testurls)
num2hash = dict([ (i, "%x"% (testurls[i][1].__hash__() +0x80000000)) for i in range(urlcount)])
hash2url = dict([ (num2hash[i], testurls[i][1]) for i in range(urlcount)])
hash2num = dict([ (num2hash[num], num) for num in num2hash ])
info = {}
try:
page = int(page)
except:
pass
if page in num2hash:
page = num2hash[page]
if not page in hash2url:
page = num2hash[0]
hash = page
assert(hash not in num2hash)
num = hash2num[hash]
info["next"] = num2hash[ (num + 1) % urlcount ]
info["this"] = hash
info["prev"] = num2hash[ (num - 1 + urlcount) % urlcount ]
info["new"] = "http://%s/%s" % (host, testurls[num][1][1:])
info["old"] = testurls[num][2]
return info
def review(request, page=0, panes=None):
return render("utils/frame2.html", {"info": get_info(page) })
def top(request, page=0):
return render("utils/review.html", {"info": get_info(page) })
def all(request):
get_info(0) # prime the list
info = []
for i in range(urlcount):
item = {}
item["num"] = num2hash[i]
item["new"] = testurls[i][1]
item["old"] = testurls[i][2]
info.append(item)
return render("utils/all.html", {"info": info, "count": len(info) })