Skip to content

Instantly share code, notes, and snippets.

View hughsaunders's full-sized avatar

Hugh Saunders hughsaunders

View GitHub Profile
@hughsaunders
hughsaunders / LDAPRemoteUserBackend.py
Created June 23, 2011 15:12
Django RemoteUserBackend for REMOTE_USER authentication and LDAP authorisation
# LDAP Remote User Backend for Django 1.3
# Hugh Saunders - [email protected]
# Written for the Surgical Materials Testing Laboratory - http://smtl.co.uk
# 2011
from django.contrib.auth.backends import RemoteUserBackend
import settings as s
import ldap
class LDAPRemoteUserBackend(RemoteUserBackend):
@hughsaunders
hughsaunders / django_search_view.py
Created June 17, 2011 12:18
Search View using Julien Phalip's technique.
def search(request):
search_string=request.POST['search_string']
if re.match(r'^\s*$',search_string): return redirect('home')
results=[]
search_fields=('id','name')
equipment_models = \
[model for model in django.db.models.get_models() if\
model._meta.db_table.startswith("equipment_")]
for model in equipment_models:
query=halipsearch.get_query(search_string,search_fields)