Skip to content
This repository was archived by the owner on May 13, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
2795549
Preliminary OpenSearch implementation:
kusamau Sep 26, 2013
eb0358c
Parametrizes the URL root path
kusamau Sep 27, 2013
9a19b68
Fix "turtle" definition
kusamau Sep 30, 2013
f6bf756
missing from the previous commit
kusamau Sep 30, 2013
4c649bd
Implements OpenSearch on http://purl.org/dc/terms/title and target URI
kusamau Oct 1, 2013
1bd04ab
Corrects some HTTP 'Access-Control' configuration
kusamau Oct 1, 2013
a307d25
- Updates the ICD document with User Case 3/4
kusamau Oct 2, 2013
b5f9328
- Access-Control-Allow-Headers missed the X-CSFRToken
kusamau Oct 2, 2013
5acb015
OPEN - task 7: OpenSearch "status" parameter return HTTP503
kusamau Nov 7, 2013
dd284e9
OPEN - task 7: OpenSearch "status" parameter return HTTP503
kusamau Nov 8, 2013
c5fec11
OPEN - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
e285724
OPEN - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
be8ddcf
OPEN - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
603481e
OPEN - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
f585b84
OPEN - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
6dcc7d7
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
837f5bc
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
3959b4c
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 19, 2013
d2519cc
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 28, 2013
0a9817d
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 28, 2013
dacbf0c
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Nov 29, 2013
91ffc02
Better paging for the sparql queries mapping:
kusamau Nov 29, 2013
be876ca
Fixes the totalResult issue
kusamau Nov 29, 2013
0f6803b
Fixes a bug in LIMIT&OFFSET parameters
kusamau Dec 2, 2013
dddada7
CLOSED - task 8: Fetching citation metadata on the server side
kusamau Dec 2, 2013
fab35b5
Fixes the issue #14
kusamau Dec 5, 2013
25b198b
Implements the registration/login workflow
kusamau Dec 13, 2013
bdec1f6
Implements the OAuth but comment it out for the moment
kusamau Jan 27, 2014
81323ca
Resets the local setting
kusamau Jan 27, 2014
b7cf7d8
light restyling
kusamau Jan 27, 2014
67a947d
Implements the OAuth.
kusamau Feb 10, 2014
598fd21
guarantee djcharme to use the CEDA customized django-oauth, until
kusamau Feb 10, 2014
d5a7cf6
missing '='
kusamau Feb 10, 2014
a0dac4b
Adds
kusamau Feb 19, 2014
46bf201
Altered security filters in order to support filtering by HTTP method as
philipkershaw Feb 25, 2014
0ec1a50
Fixes for Iteration 3: changed security filter to work based on URL _…
philipkershaw Mar 11, 2014
7f91011
Fixing formatting, parameterising literals as class or module vars, c…
philipkershaw Mar 24, 2014
e93984a
Merge branch 'develop' of github.com:philipkershaw/djcharme into phil…
philipkershaw Mar 24, 2014
40daa25
remove graph from return of insert
antony-wilson Mar 31, 2014
f208eb2
rearrange settings and fix some pylint complaints
antony-wilson Mar 31, 2014
cd990f2
pylint fixes
antony-wilson Mar 31, 2014
14ce4cb
update wsgi parameters
antony-wilson Mar 31, 2014
45ccef2
add WSGISocketPrefix
antony-wilson Apr 1, 2014
66a409e
front page and login
antony-wilson Apr 1, 2014
abb62e5
login redirects
antony-wilson Apr 2, 2014
45c461c
back out redirect changes, worked on my machine but not on charme node
antony-wilson Apr 2, 2014
a3426d5
improve error reporting
antony-wilson Apr 4, 2014
6f696a7
more logging
antony-wilson Apr 4, 2014
ef7d597
allow search
antony-wilson Apr 4, 2014
4f78d4b
Beta message
antony-wilson Apr 7, 2014
5162587
tidy login and registration and add logout
antony-wilson Apr 9, 2014
69d7125
update OPTIONS_HEADER_RESPONSE
antony-wilson Apr 9, 2014
c8f9d20
allow data in the filter, update log messages
antony-wilson Apr 10, 2014
082f453
move ref to css
antony-wilson Apr 10, 2014
7fa2509
fix for DEFAULT_OPTIONS_HDR_RESPONSE & pylint stuff
antony-wilson Apr 11, 2014
ae97419
change Http404 to HttpResponseNotFound and pylint fixes
antony-wilson Apr 15, 2014
7cda815
change to using username rather than email to login
antony-wilson May 14, 2014
7736a3d
pylint stuff
antony-wilson May 14, 2014
4f042e3
pylint stuff
antony-wilson May 14, 2014
9277d8c
pylint stuff
antony-wilson May 14, 2014
3d5a7de
more pylint stuff
antony-wilson May 23, 2014
20069ed
added domainOfInterest and dataType searches
antony-wilson May 29, 2014
ad2270e
logging stuff
antony-wilson May 30, 2014
7356643
add motivation and organization to open search
antony-wilson May 30, 2014
e5e13f7
us spelling
antony-wilson May 30, 2014
8d42ce1
remove None from insert responce
antony-wilson Jun 2, 2014
21dbeb7
improve error handling for duff inserts
antony-wilson Jun 2, 2014
4e78e88
search terms
antony-wilson Jun 3, 2014
ea2ab92
add suggest to open search
antony-wilson Jun 5, 2014
d8f8639
open search suggest
antony-wilson Jun 5, 2014
19eb766
merged
antony-wilson Jun 9, 2014
6759f33
Merge branch 'develop' of https://github.com/cedadev/djcharme into de…
antony-wilson Jun 9, 2014
3dc2c57
stuff for suggest
antony-wilson Jun 10, 2014
da04f6b
open search, now uses multiple terms
antony-wilson Jun 11, 2014
94a2042
open search and prov person
antony-wilson Jun 13, 2014
eb15dda
suggest fix and agent bits
antony-wilson Jun 18, 2014
d7df31a
improve error handling and return anno uri after insert
antony-wilson Jun 18, 2014
e60e1a9
interim check in
antony-wilson Jun 19, 2014
399fec1
format types
antony-wilson Jun 19, 2014
89aba21
prov: Organization
antony-wilson Jun 20, 2014
230751c
prov Organization
antony-wilson Jun 20, 2014
85e3450
allow access to page and resource
antony-wilson Jun 20, 2014
a25d948
update sample organization name
antony-wilson Jun 20, 2014
1490419
fix for suggest for organization
antony-wilson Jun 20, 2014
d7f7871
added multi target example
antony-wilson Jun 24, 2014
c405cce
update version number
antony-wilson Jul 17, 2014
4160d7b
quick hack for json-ld
antony-wilson Jul 18, 2014
244d4c7
fix for Accept for endpoint
antony-wilson Jul 24, 2014
eff87c0
add default HTTP_ACCEPT to comply with
antony-wilson Jul 24, 2014
91169b6
user managment
antony-wilson Aug 19, 2014
265f514
suggest fix
antony-wilson Aug 20, 2014
0aad858
typo
antony-wilson Aug 20, 2014
0c06804
fix for site name
antony-wilson Aug 20, 2014
e862e06
fix body
antony-wilson Aug 20, 2014
124b501
advabce_status stuff
antony-wilson Aug 21, 2014
bb98d81
https fix
antony-wilson Aug 21, 2014
382af28
fix True/False
antony-wilson Aug 21, 2014
49a4cdc
moderator stuff
antony-wilson Aug 21, 2014
7afc95b
update advance_status docs
antony-wilson Aug 22, 2014
147adf1
Show email in annotations
antony-wilson Sep 1, 2014
fe7f987
Show my email in annotations
antony-wilson Sep 1, 2014
366b808
fix for transition to show email
antony-wilson Sep 2, 2014
97ce39f
fix url
antony-wilson Sep 2, 2014
9ee7fee
https and suggest stuff
antony-wilson Sep 3, 2014
f57564c
sort graphs
antony-wilson Sep 3, 2014
a7f696e
show username in results
antony-wilson Sep 4, 2014
a80c116
fix sort order
antony-wilson Sep 5, 2014
98c6b33
order graphs
antony-wilson Sep 11, 2014
f95f236
iteration 5
antony-wilson Sep 11, 2014
c111d51
vocab
antony-wilson Sep 11, 2014
7ad026a
ignore stuff
antony-wilson Oct 1, 2014
34dc99b
iteration 5
antony-wilson Oct 1, 2014
b0208f5
fix for sorting
antony-wilson Oct 1, 2014
c811daa
advance_status fix and htp DELETE
antony-wilson Oct 2, 2014
fff2a2e
changes for FGC
antony-wilson Oct 16, 2014
5fa9d25
modify call and refactoring of some constants
antony-wilson Oct 21, 2014
b8294ac
search bodyType and more logging
antony-wilson Oct 28, 2014
b0aaac2
update version nos and add version call
antony-wilson Oct 28, 2014
981e5f0
downgrade html5lib back down to 0.95
antony-wilson Oct 28, 2014
536e3cf
add DELETE to OPTIONS
antony-wilson Oct 29, 2014
35cb230
Add depth and format parameters onto the path when doing a redirect
antony-wilson Oct 29, 2014
739120f
remove logging that printed out all returned annotations
antony-wilson Oct 29, 2014
c0c8ce5
improve error handling
antony-wilson Oct 30, 2014
e88859f
vocab stuff
antony-wilson Oct 30, 2014
5acd95d
downgrade versions as they were causes issues as the '@graph' was no
antony-wilson Nov 4, 2014
c0e1df2
search on composite
antony-wilson Nov 6, 2014
c0a402e
site admin functionality
antony-wilson Nov 14, 2014
7bf7168
version 0.6.0
antony-wilson Nov 17, 2014
2b1fcc2
conditions of use
antony-wilson Nov 18, 2014
8795095
strabon stuff
antony-wilson Nov 20, 2014
f7668e2
conditions of use
antony-wilson Nov 20, 2014
817c517
depth and prov fixes
antony-wilson Nov 21, 2014
8a9d855
fix for depth
antony-wilson Nov 21, 2014
c52ada0
version 0.6.2
antony-wilson Nov 25, 2014
8cea2c1
search on citing type
antony-wilson Nov 25, 2014
30417a7
citingType
antony-wilson Nov 26, 2014
a45b631
citingType added to opensearch
antony-wilson Nov 26, 2014
2f69cc7
fixes for email and title search
antony-wilson Nov 28, 2014
1d4fdfc
version 0.6.4
antony-wilson Dec 1, 2014
2ca8783
fix for suggest organization and strabon
antony-wilson Dec 8, 2014
2246eee
graph validation
antony-wilson Dec 12, 2014
53c7479
version 0.6.6
antony-wilson Dec 12, 2014
4dc1659
report to moderator
antony-wilson Jan 7, 2015
3dc96dc
report to moderator
antony-wilson Jan 7, 2015
c22bb54
add PUT to OPTIONS_HDR_RESPONSE
antony-wilson Jan 8, 2015
a159252
more moderation
antony-wilson Jan 8, 2015
9947ae7
release 0.7.0
antony-wilson Jan 9, 2015
90b28b2
display more info
antony-wilson Jan 9, 2015
841f044
revert
antony-wilson Jan 9, 2015
e4da79a
remove print statements
antony-wilson Jan 20, 2015
cadc2ee
display more info
antony-wilson Jan 20, 2015
35ed7a8
remove work around for plugin doing annotations of annotations
antony-wilson Jan 20, 2015
a5e4280
add check before making 'Value' a hyperlink
antony-wilson Jan 20, 2015
b104602
new doc
antony-wilson Jan 22, 2015
8337525
fix for apostrophe in users text
antony-wilson Jan 22, 2015
ce7e007
wasInvalidatedBy and wasRevisionOf are now included on the resource page
antony-wilson Jan 22, 2015
9bef91a
prov activity
antony-wilson Jan 22, 2015
2c65aa8
add title field
antony-wilson Jan 26, 2015
dea8ad1
delete target
antony-wilson Jan 27, 2015
3f418fa
delete body
antony-wilson Jan 27, 2015
aa09e0d
provide templates for annotations and activities
antony-wilson Jan 30, 2015
a2837ea
remove print
antony-wilson Jan 30, 2015
23a9ab8
version 0.7.1
antony-wilson Jan 30, 2015
5a9d850
version 0.7.1
antony-wilson Jan 30, 2015
0820c9f
title and typos
antony-wilson Feb 3, 2015
3f789da
changes to resource views
antony-wilson Feb 4, 2015
109825b
more tweaks to annotation display
antony-wilson Feb 4, 2015
05584bd
typo
antony-wilson Feb 12, 2015
43e317a
new file
antony-wilson Feb 12, 2015
507de48
added strabon
antony-wilson Feb 17, 2015
3da9af9
username reminder
antony-wilson Feb 18, 2015
c0bc4da
release 0.7.2
antony-wilson Feb 18, 2015
a6d9cbc
fix for fine grained commentary
antony-wilson Feb 25, 2015
fb2420e
examples
antony-wilson Feb 26, 2015
b23d241
docs
antony-wilson Feb 26, 2015
afb1a40
update links
antony-wilson Feb 26, 2015
3a3b9df
move docs to doc dir
antony-wilson Feb 26, 2015
211c8c5
more links
antony-wilson Feb 26, 2015
daa6f6e
typo
antony-wilson Feb 26, 2015
c86d268
rename
antony-wilson Feb 26, 2015
e95f9a1
typo
antony-wilson Feb 26, 2015
7473d62
more examples
antony-wilson Feb 26, 2015
9e4f680
typo
antony-wilson Feb 26, 2015
ace91ce
more italics
antony-wilson Feb 26, 2015
d4a04a7
update agent
antony-wilson Feb 26, 2015
9202c18
release 0.7.3
antony-wilson Feb 26, 2015
fae8d39
refactor localhost name
antony-wilson Apr 7, 2015
bfaf86a
dcterms typo
antony-wilson May 27, 2015
0901c6a
add free text search on comment
antony-wilson May 27, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
djcharme
========

CHARMe project node


See the
`docs directory <https://github.com/cedadev/djcharme/tree/develop/djcharme/docs>`_
for information on
`installation <https://github.com/cedadev/djcharme/blob/develop/djcharme/docs/CHARMeNodeInstallation.pdf>`_,
the
`interface <https://github.com/cedadev/djcharme/blob/develop/djcharme/docs/CHARMeNodeICD.pdf>`_
and examples.
8 changes: 1 addition & 7 deletions djcharme/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
/dist
/build
/djcharme.egg-info
/deployIndjcharme.sh
/deployIndjcharme.sh~
/sqlite.db
/.settings
/.project
/.pydevproject
Binary file removed djcharme/CHARMeNodeICDv0.1.odt
Binary file not shown.
Binary file modified djcharme/CHARMeTechnicalReference.odt
Binary file not shown.
38 changes: 19 additions & 19 deletions djcharme/LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

BSD Licence
Copyright (c) 2012, Science & Technology Facilities Council (STFC)
Copyright (c) 2015, Science & Technology Facilities Council (STFC)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Science & Technology Facilities Council (STFC)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.
this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Science & Technology Facilities Council (STFC)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions djcharme/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include LICENSE
recursive-include docs *
recursive-include djcharme/resources *
recursive-include djcharme/templates *
recursive-include djcharme/static *
7 changes: 0 additions & 7 deletions djcharme/README

This file was deleted.

File renamed without changes.
Binary file added djcharme/dist/djcharme-0.5.0.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.6.0.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.6.2.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.6.3.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.6.4.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.6.6.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.7.0.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.7.1.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.7.2.tar.gz
Binary file not shown.
Binary file added djcharme/dist/djcharme-0.7.3.tar.gz
Binary file not shown.
7 changes: 2 additions & 5 deletions djcharme/djcharme/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/__init__.pyc
/local_settings.pyc
/settings.pyc
/urls.pyc
/wsgi.pyc
/*.pyc
/sqlite.db
81 changes: 63 additions & 18 deletions djcharme/djcharme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,94 @@
__version__ = '0.1'
'''
BSD Licence
Copyright (c) 2015, Science & Technology Facilities Council (STFC)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Science & Technology Facilities Council (STFC)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

'''
__version__ = '0.7.3'


import os

from django.conf import settings
from django.core.context_processors import csrf
from django.template.context import RequestContext
from django.shortcuts import render_to_response, render
from django.http.response import Http404
from django.core.exceptions import ObjectDoesNotExist
from django.http.response import Http404
from django.shortcuts import render_to_response, render
from django.template.context import RequestContext


LOAD_SAMPLE = 'LOAD_SAMPLE'
HTTP_PROXY = 'HTTP_PROXY'
HTTP_PROXY_PORT = 'HTTP_PROXY_PORT'


def get_resource(file_name):
return os.path.join(__path__[0], 'resources', file_name)


def mm_render_to_response(request, context, page_to_render):
"""
Exploits a 'render_to_response' action. The advantage of this method
is to contains a number of operations that are expected to be called
for each page rendering, for example passing the application version number
**Parameters**

**Parameters**
* HttpRequest_ **request**
a django HttpRequest instance
a django HttpRequest instance
* `dict` **context**
a dictionary where to pass parameter to the rendering function
a dictionary where to pass parameter to the rendering function
* `string` **page_to_render**
the html page to render
the html page to render
"""
if context is None or not isinstance(context, dict):
raise Exception("Cannot render an empty context")
#context['version'] = assemble_version()

# context['version'] = assemble_version()
context.update(csrf(request))
rcontext = RequestContext(request, context)
return render_to_response(page_to_render, rcontext)


def mm_render_to_response_error(request, page_to_render, status):
"""
Exploits a 'render_to_response' action. The advantage of this method
is to contains a number of operations that are expected to be called
for each page rendering, for example passing the application version number
**Parameters**

**Parameters**
* HttpRequest_ **request**
a django HttpRequest instance
a django HttpRequest instance
* `dict` **context**
a dictionary where to pass parameter to the rendering function
a dictionary where to pass parameter to the rendering function
* `string` **page_to_render**
the html page to render
the html page to render
"""
context = {}
context = {}
context.update(csrf(request))
rcontext = RequestContext(request, context)
return render(request, page_to_render, context_instance = rcontext, status = status)
return render(request, page_to_render, context_instance=rcontext,
status=status)
139 changes: 139 additions & 0 deletions djcharme/djcharme/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"""
Admin stuff.

"""
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from djcharme.models import UserProfile, Organization, OrganizationClient, \
OrganizationUser
from provider.oauth2.admin import ClientAdmin
from provider.oauth2.models import Client


class UserProfileInline(admin.StackedInline):
"""
The in-line display of the User Profile.

"""
model = UserProfile
can_delete = False
verbose_name = 'Profile'
verbose_name_plural = 'Profiles'
list_display = ('show_email')


class OrganizationUserInline(admin.StackedInline):
"""
The in-line display of the Organization User.

"""
model = OrganizationUser
can_delete = False
verbose_name = 'Role'
verbose_name_plural = 'Roles'
list_display = ('organization', 'role')
extra = 1


class OrganizationClientInline(admin.StackedInline):
"""
The in-line display of the Organization Client.

"""
model = OrganizationClient
verbose_name = 'Organization'
verbose_name_plural = 'Organization'
extra = 1
fk_name = "client"


class OrganizationAdmin(admin.ModelAdmin):
"""
The Organization Admin.

"""
list_display = ('name', 'primary_email')


class OrganizationClientAdmin(admin.ModelAdmin):
"""
The Organization Client Admin.

"""
list_display = ('organization', 'client')
list_filter = ['organization']


class OrganizationUserAdmin(admin.ModelAdmin):
"""
The Organization User Admin.

"""
fields = ['organization', 'user', 'role']
list_display = ('organization', 'user', 'role')
list_filter = ['organization', 'user']


class ClientAdmin_(ClientAdmin):
"""
The new version of ClientAdmin, which includes the Organization Client.

"""
inlines = [OrganizationClientInline]
list_display = ('url', 'get_organization', 'redirect_uri', 'client_id',
'client_type')

def get_organization(self, obj):
"""
Get the name of the organization, there should only be one.

"""
return obj.organizationclient_set.first()

get_organization.short_description = 'organization'


class UserAdmin_(UserAdmin):
"""
The new version of UserAdmin, which includes the User Profile and
Organization User.

"""
inlines = [UserProfileInline, OrganizationUserInline]
list_display = ('username', 'get_role', 'email', 'first_name', 'last_name',
'is_staff')

def get_role(self, obj):
"""
Get the role of the user, they may have more than one role.

"""
admin_ = False
user = False
for organizationuser in obj.organizationuser_set.iterator():
if organizationuser.role == 'admin':
admin_ = True
else:
user = True

if admin_ and user:
return 'admin & user'
elif admin_:
return 'admin'
elif admin_:
return 'user'
else:
return ''

get_role.short_description = 'roles in organizations'


# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin_)
admin.site.unregister(Client)
admin.site.register(Client, ClientAdmin_)
admin.site.register(Organization, OrganizationAdmin)
admin.site.register(OrganizationUser, OrganizationUserAdmin)
admin.site.register(OrganizationClient, OrganizationClientAdmin)
Loading