Example #1
0
def show_profile(request, username):
    user = get_object_or_404(controller.get_profile_model(), user__username=username)

    profile_base = getattr(settings, "PROFILE_BASE", "user_profile/user_profile_base.html")
    extends_from = getattr(settings, "EXTENDS_FROM", "base.html")
    context = {"profile": user, "extends_from": extends_from}
    return render_to_response(profile_base, context, context_instance=RequestContext(request))
Example #2
0
#coding: utf-8
import random

from django import template
from django.contrib.auth.models import User

from user_profile.settings import controller
from phonebook.forms import UserSearchForm

register = template.Library()

profile_model = controller.get_profile_model()
 
 
def phonebook_search_form(query = ""):
    form = UserSearchForm(auto_id = "search-form-%s", initial = {'query': query })
    form.id = "search-form"
    return {'form' : form , 'dict': form.__dict__}
register.inclusion_tag('phonebook/forms/search_form.html')(phonebook_search_form)

def get_random_user():
    """
    Usage:  {% get_random_user %}
    After:  A random user has been selected from the database and displayed
    """
    user = User.objects.all()[random.randrange(0, User.objects.count())]
    return {'profile': user.get_profile() }
register.inclusion_tag('phonebook/snippets/random_user.html')(get_random_user)
    

def get_list_of_users(parser, token):
Example #3
0
def save_user(sender, instance, created, raw, **kwargs):
    if created:
        profile = controller.get_profile_model().objects.create(user=instance)
Example #4
0
#! /usr/bin/env python
# -*- coding: utf8 -*-

import os

from django.contrib.auth.models import User
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext_lazy as _
from django.conf import settings

from user_profile.settings import controller
from user_profile.models import Website, DisplayImage
from user_profile.forms import UserProfileForm, DisplayImageForm, AdminImageFieldWidget

UserProfile = controller.get_profile_model()


def display_user_fullname(user):
    """
    Usage:     user_fullname = display_user_fullname(user)
    Post:      user_fullname is the fullname of the user
    """
    try:
        profile = user.get_profile()
    except UserProfile.DoesNotExist:
        return u"%s %s" % (user.first_name, user.last_name)
    else:
        return profile.short_fullname

Example #5
0
#coding: utf-8
from django.db import connection, backend, models
from django.contrib.auth.models import User

import user_profile
from user_profile.settings import controller

PROFILE_MODEL = controller.get_profile_model()

def create_search_view(sender, app, created_models, verbosity, interactive, **kwargs):
    VIEW_SQL = """
                CREATE OR REPLACE VIEW phonebook_usersearchview
                    (profile_id,
                        username,
                        kennitala,
                        fullname,
                        fullname_sans_middlename,
                        first_name,
                        middlenames,
                        last_name,
                        address,
                        phone,
                        gsm)
                AS
                    SELECT
                        p.id as profile_id,
                        u.username as username,
                        p.kennitala as kennitala,
                        u.first_name || ' ' || p.middlenames || ' ' || u.last_name as fullname,
                        u.first_name || ' ' || u.last_name as fullname_sans_middlename,
                        u.first_name as first_name,