-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from avallbona/develop
version v2.0.4
- Loading branch information
Showing
14 changed files
with
125 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Marko Samastur | ||
* Andreu Vallbona |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
recursive-include impostor/templates *.html | ||
include AUTHORS | ||
include LICENSE | ||
include CHANGELOG.MD | ||
include README.md | ||
recursive-include impostor * | ||
global-exclude *.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
"""Impostor.""" | ||
__VERSION__ = "2.0.3" | ||
__version__ = "2.0.4" | ||
__author__ = "Marko Samastur" | ||
__email__ = "[email protected]" | ||
__mantainer__ = "Andreu Vallbona" | ||
__mantainer_email__ = "[email protected]" | ||
default_app_config = "impostor.apps.ImpostorConfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
|
||
class ImpostorConfig(AppConfig): | ||
name = 'Impostor' | ||
name = 'impostor' | ||
verbose_name = 'Impostor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% load i18n impostor_tags%} | ||
|
||
|
||
{% block welcome-msg %} | ||
{% trans 'Welcome,' %} | ||
{% get_impersonated_as request as impersonated_as %} | ||
{% if not impersonated_as %} | ||
<strong>{% firstof user.get_short_name user.get_username %}</strong>. | ||
{% else %} | ||
<span class="loggedAs"> | ||
<strong>{% firstof impersonated_as.impostor %}</strong> | ||
{% trans ' logged as '%} | ||
<strong>{% firstof impersonated_as.imposted_as %}</strong>. | ||
</span> | ||
{% endif %} | ||
{% endblock %} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""template tags for impostor.""" | ||
|
||
from django import template | ||
from impostor.models import ImpostorLog | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def get_impersonated_as(request): | ||
"""return the impersonated_as template tag to include into the main template. | ||
:param request: | ||
:return: | ||
""" | ||
try: | ||
impersonated_as = ImpostorLog.objects.get(token=request.session['impostor_token']) | ||
except (ImpostorLog.DoesNotExist, KeyError): | ||
impersonated_as = None | ||
|
||
return impersonated_as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,16 @@ | ||
import codecs | ||
import os | ||
import sys | ||
import re | ||
|
||
from setuptools import find_packages | ||
from setuptools import setup, find_packages | ||
|
||
from distutils.command.install import INSTALL_SCHEMES | ||
from distutils.command.install_data import install_data | ||
from distutils.core import setup | ||
|
||
|
||
class OsxInstallData(install_data): | ||
# On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../ | ||
# which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix | ||
# for this in distutils.command.install_data#306. It fixes install_lib but not | ||
# install_data, which is why we roll our own install_data class. | ||
|
||
def finalize_options(self): | ||
# By the time finalize_options is called, install.install_lib is set to the | ||
# fixed directory, so we set the installdir to install_lib. The | ||
# install_data class uses ('install_data', 'install_dir') instead. | ||
self.set_undefined_options('install', ('install_lib', 'install_dir')) | ||
install_data.finalize_options(self) | ||
|
||
|
||
if sys.platform == "darwin": | ||
cmdclasses = {'install_data': OsxInstallData} | ||
else: | ||
cmdclasses = {'install_data': install_data} | ||
|
||
|
||
def fullsplit(path, result=None): | ||
def get_metadata(package, field): | ||
""" | ||
Split a pathname into components (the opposite of os.path.join) in a platform-neutral way. | ||
:param path: | ||
:param result: | ||
:return: | ||
Return package data as listed in `__{field}__` in `init.py`. | ||
""" | ||
if result is None: | ||
result = [] | ||
head, tail = os.path.split(path) | ||
if head == '': | ||
return [tail] + result | ||
if head == path: | ||
return result | ||
return fullsplit(head, [tail] + result) | ||
|
||
|
||
# Tell distutils to put the data_files in platform-specific installation | ||
# locations. See here for an explanation: | ||
# http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb | ||
for scheme in INSTALL_SCHEMES.values(): | ||
scheme['data'] = scheme['purelib'] | ||
|
||
# Compile the list of packages available, because distutils doesn't have | ||
# an easy way to do this. | ||
packages, data_files = [], [] | ||
root_dir = os.path.dirname(__file__) | ||
if root_dir != '': | ||
os.chdir(root_dir) | ||
impostor_dir = 'impostor' | ||
|
||
for dirpath, dirnames, filenames in os.walk(impostor_dir): | ||
# Ignore dirnames that start with '.' | ||
for i, dirname in enumerate(dirnames): | ||
if dirname.startswith('.'): | ||
del dirnames[i] | ||
if '__init__.py' in filenames: | ||
packages.append('.'.join(fullsplit(dirpath))) | ||
elif filenames: | ||
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]]) | ||
|
||
# Small hack for working with bdist_wininst. | ||
# See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html | ||
if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst': | ||
for file_info in data_files: | ||
file_info[0] = '\\PURELIB\\%s' % file_info[0] | ||
init_py = codecs.open(os.path.join(package, '__init__.py'), encoding='utf-8').read() | ||
return re.search("^__{}__ = ['\"]([^'\"]+)['\"]".format(field), init_py, re.MULTILINE).group(1) | ||
|
||
|
||
def read(fname): | ||
|
@@ -91,20 +26,19 @@ def read(fname): | |
|
||
setup( | ||
name="Impostor", | ||
version="2.0.3", | ||
version=get_metadata('impostor', 'version'), | ||
url='https://github.com/avallbona/Impostor/', | ||
author='Marko Samastur', | ||
author_email='[email protected]', | ||
maintainer='Andreu Vallbona', | ||
maintainer_email='[email protected]', | ||
author=get_metadata('impostor', 'author'), | ||
author_email=get_metadata('impostor', 'email'), | ||
maintainer=get_metadata('impostor', 'mantainer'), | ||
maintainer_email=get_metadata('impostor', 'mantainer_email'), | ||
description='Staff can login as a different user.', | ||
long_description=read('README.md'), | ||
long_description_content_type='text/markdown', | ||
license='MIT License', | ||
platforms=['any'], | ||
packages=find_packages(exclude=['tests*']), | ||
cmdclass=cmdclasses, | ||
data_files=data_files, | ||
include_package_data=True, | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Environment :: Web Environment', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters