Permalink
Browse files

Initial Commit to github and start of open source distibution. This i…

…s not perfect!

Big changes to be less dependent of the settings.py
Major hack in Admin.py and the admin templates to make it work as a package.
  • Loading branch information...
1 parent 6464acf commit 7b87020022dcbc5359d3d2f31d8998eac422adf0 @belug23 belug23 committed Jan 27, 2013
Showing with 7,965 additions and 3 deletions.
  1. +14 −0 CHANGELOG
  2. +7 −0 MANIFEST.in
  3. +7 −3 README.md
  4. 0 geoprisma_config/__init__.py
  5. +321 −0 geoprisma_config/admin.py
  6. 0 geoprisma_config/conf/__init__.py
  7. +81 −0 geoprisma_config/conf/types.py
  8. +4 −0 geoprisma_config/context_processors.py
  9. +133 −0 geoprisma_config/forms.py
  10. 0 geoprisma_config/management/__init__.py
  11. 0 geoprisma_config/management/commands/__init__.py
  12. +689 −0 geoprisma_config/management/commands/import.py
  13. +269 −0 geoprisma_config/models.py
  14. +827 −0 geoprisma_config/static/admin/gc_css/base.css
  15. +252 −0 geoprisma_config/static/admin/gc_css/changelists.css
  16. +24 −0 geoprisma_config/static/admin/gc_css/dashboard.css
  17. +325 −0 geoprisma_config/static/admin/gc_css/forms.css
  18. +51 −0 geoprisma_config/static/admin/gc_css/ie.css
  19. +54 −0 geoprisma_config/static/admin/gc_css/login.css
  20. +206 −0 geoprisma_config/static/admin/gc_css/rtl.css
  21. +506 −0 geoprisma_config/static/admin/gc_css/widgets.css
  22. BIN geoprisma_config/static/admin/gc_img/admin/arrow-down.gif
  23. BIN geoprisma_config/static/admin/gc_img/admin/arrow-up.gif
  24. BIN geoprisma_config/static/admin/gc_img/admin/changelist-bg.gif
  25. BIN geoprisma_config/static/admin/gc_img/admin/changelist-bg_rtl.gif
  26. BIN geoprisma_config/static/admin/gc_img/admin/chooser-bg.gif
  27. BIN geoprisma_config/static/admin/gc_img/admin/chooser_stacked-bg.gif
  28. BIN geoprisma_config/static/admin/gc_img/admin/default-bg-reverse.gif
  29. BIN geoprisma_config/static/admin/gc_img/admin/default-bg.gif
  30. BIN geoprisma_config/static/admin/gc_img/admin/deleted-overlay.gif
  31. BIN geoprisma_config/static/admin/gc_img/admin/icon-no.gif
  32. BIN geoprisma_config/static/admin/gc_img/admin/icon-unknown.gif
  33. BIN geoprisma_config/static/admin/gc_img/admin/icon-yes.gif
  34. BIN geoprisma_config/static/admin/gc_img/admin/icon_addlink.gif
  35. BIN geoprisma_config/static/admin/gc_img/admin/icon_alert.gif
  36. BIN geoprisma_config/static/admin/gc_img/admin/icon_calendar.gif
  37. BIN geoprisma_config/static/admin/gc_img/admin/icon_changelink.gif
  38. BIN geoprisma_config/static/admin/gc_img/admin/icon_clock.gif
  39. BIN geoprisma_config/static/admin/gc_img/admin/icon_deletelink.gif
  40. BIN geoprisma_config/static/admin/gc_img/admin/icon_error.gif
  41. BIN geoprisma_config/static/admin/gc_img/admin/icon_searchbox.png
  42. BIN geoprisma_config/static/admin/gc_img/admin/icon_success.gif
  43. BIN geoprisma_config/static/admin/gc_img/admin/inline-delete-8bit.png
  44. BIN geoprisma_config/static/admin/gc_img/admin/inline-delete.png
  45. BIN geoprisma_config/static/admin/gc_img/admin/inline-restore-8bit.png
  46. BIN geoprisma_config/static/admin/gc_img/admin/inline-restore.png
  47. BIN geoprisma_config/static/admin/gc_img/admin/inline-splitter-bg.gif
  48. BIN geoprisma_config/static/admin/gc_img/admin/nav-bg-grabber.gif
  49. BIN geoprisma_config/static/admin/gc_img/admin/nav-bg-reverse.gif
  50. BIN geoprisma_config/static/admin/gc_img/admin/nav-bg.gif
  51. BIN geoprisma_config/static/admin/gc_img/admin/selector-add.gif
  52. BIN geoprisma_config/static/admin/gc_img/admin/selector-addall.gif
  53. BIN geoprisma_config/static/admin/gc_img/admin/selector-remove.gif
  54. BIN geoprisma_config/static/admin/gc_img/admin/selector-removeall.gif
  55. BIN geoprisma_config/static/admin/gc_img/admin/selector-search.gif
  56. BIN geoprisma_config/static/admin/gc_img/admin/selector_stacked-add.gif
  57. BIN geoprisma_config/static/admin/gc_img/admin/selector_stacked-remove.gif
  58. BIN geoprisma_config/static/admin/gc_img/admin/tool-left.gif
  59. BIN geoprisma_config/static/admin/gc_img/admin/tool-left_over.gif
  60. BIN geoprisma_config/static/admin/gc_img/admin/tool-right.gif
  61. BIN geoprisma_config/static/admin/gc_img/admin/tool-right_over.gif
  62. BIN geoprisma_config/static/admin/gc_img/admin/tooltag-add.gif
  63. BIN geoprisma_config/static/admin/gc_img/admin/tooltag-add_over.gif
  64. BIN geoprisma_config/static/admin/gc_img/admin/tooltag-arrowright.gif
  65. BIN geoprisma_config/static/admin/gc_img/admin/tooltag-arrowright_over.gif
  66. BIN geoprisma_config/static/admin/gc_img/gis/move_vertex_off.png
  67. BIN geoprisma_config/static/admin/gc_img/gis/move_vertex_on.png
  68. +111 −0 geoprisma_config/static/admin/gc_js/SelectBox.js
  69. +113 −0 geoprisma_config/static/admin/gc_js/SelectFilter2.js
  70. +39 −0 geoprisma_config/static/admin/gc_js/actions.js
  71. +85 −0 geoprisma_config/static/admin/gc_js/admin/CollapsedFieldsets.js
  72. +255 −0 geoprisma_config/static/admin/gc_js/admin/DateTimeShortcuts.js
  73. +96 −0 geoprisma_config/static/admin/gc_js/admin/RelatedObjectLookups.js
  74. +137 −0 geoprisma_config/static/admin/gc_js/admin/ordering.js
  75. +143 −0 geoprisma_config/static/admin/gc_js/calendar.js
  76. +176 −0 geoprisma_config/static/admin/gc_js/core.js
  77. +233 −0 geoprisma_config/static/admin/gc_js/dateparse.js
  78. +167 −0 geoprisma_config/static/admin/gc_js/getElementsBySelector.js
  79. +94 −0 geoprisma_config/static/admin/gc_js/timeparse.js
  80. +140 −0 geoprisma_config/static/admin/gc_js/urlify.js
  81. +6 −0 geoprisma_config/static/gc_js/admin-inline-fix.js
  82. +86 −0 geoprisma_config/static/gc_js/admin-list-reorder.js
  83. +67 −0 geoprisma_config/static/gc_js/admin-widgets.js
  84. +154 −0 geoprisma_config/static/gc_js/jquery-1.4.2.min.js
  85. +1,012 −0 geoprisma_config/static/gc_js/jquery-ui-1.8.2.custom.min.js
  86. +12 −0 geoprisma_config/templates/admin/404.html
  87. +12 −0 geoprisma_config/templates/admin/500.html
  88. +5 −0 geoprisma_config/templates/admin/actions.html
  89. +15 −0 geoprisma_config/templates/admin/app_index.html
  90. +101 −0 geoprisma_config/templates/admin/base.html
  91. +33 −0 geoprisma_config/templates/admin/base2.html
  92. +10 −0 geoprisma_config/templates/admin/base_site.html
  93. +124 −0 geoprisma_config/templates/admin/change.html
  94. +66 −0 geoprisma_config/templates/admin/change_form.html
  95. +86 −0 geoprisma_config/templates/admin/change_list.html
  96. +17 −0 geoprisma_config/templates/admin/change_list_results.html
  97. +10 −0 geoprisma_config/templates/admin/date_hierarchy.html
  98. +32 −0 geoprisma_config/templates/admin/delete_confirmation.html
  99. +40 −0 geoprisma_config/templates/admin/delete_selected_confirmation.html
  100. +28 −0 geoprisma_config/templates/admin/edit_inline/stacked.html
  101. +71 −0 geoprisma_config/templates/admin/edit_inline/tabular.html
  102. +8 −0 geoprisma_config/templates/admin/filter.html
  103. +19 −0 geoprisma_config/templates/admin/includes/fieldset.html
  104. +80 −0 geoprisma_config/templates/admin/index.html
  105. +8 −0 geoprisma_config/templates/admin/invalid_setup.html
  106. +35 −0 geoprisma_config/templates/admin/login.html
  107. +42 −0 geoprisma_config/templates/admin/object_history.html
  108. +12 −0 geoprisma_config/templates/admin/pagination.html
  109. +11 −0 geoprisma_config/templates/admin/prepopulated_fields_js.html
  110. +18 −0 geoprisma_config/templates/admin/search_form.html
  111. +11 −0 geoprisma_config/templates/admin/submit_line.html
  112. +32 −0 geoprisma_config/templates/admin/template_validator.html
  113. +23 −0 geoprisma_config/tests.py
  114. +40 −0 geoprisma_config/urls.py
  115. +5 −0 geoprisma_config/utils.py
  116. +36 −0 geoprisma_config/views.py
  117. +6 −0 geoprisma_config/widgets.py
  118. +33 −0 setup.py
View
@@ -0,0 +1,14 @@
+0.0.1
+=====
+
+Initial Commit to github and start of open source distibution. This is not perfect!
+Big changes to be less dependent of the settings.py
+Major hack in Admin.py and the admin templates to make it work as a package.
+The Admin part of the app is to be redone.
+It needs to be tester with django 1.4 and 1.5
+
+
+0.0.0
+=====
+
+The project was create by Alan Boudreault - Mapgears inc. for Solution Globale Informatique and Nippour on the Géoctopus project.
View
@@ -0,0 +1,7 @@
+include README.md
+include LICENSE
+include CHANGELOG
+recursive-include geoprisma_config/management *
+recursive-include geoprisma_config/static *
+recursive-include geoprisma_config/templates *
+recursive-include geoprisma_config/conf *
View
@@ -12,8 +12,6 @@ Contrib Admin is required.
1. Add "geoprisma_config" to your INSTALLED_APPS setting like this::
- MEDIA_URL_geoprisma_config = '/media-geoprisma_config/'
- ....
INSTALLED_APPS = (
...
'geoprisma_config',
@@ -28,10 +26,16 @@ Contrib Admin is required.
4. Start the development server and visit http://127.0.0.1:8000/admin/
to manage your geoprisma configs (you'll need the Admin app enabled).
+Production Setup
+----------------
+
+Staticfiles is needed to work, so check https://docs.djangoproject.com/en/dev/howto/static-files/ for support.
+
Tested
------
-This app have been tested with Django 1.2 and Django 1.3, tests for django 1.4 and 1.5 are on the way.
+This app have been tested with Django 1.3, tests for django 1.4 and 1.5 are on the way.
+Django 1.2 might be ok if you add django-staticfiles app. Check https://docs.djangoproject.com/en/dev/howto/static-files/
BSD License
=======
No changes.
View
@@ -0,0 +1,321 @@
+from django.conf import settings
+from django.contrib import admin
+from django.contrib.admin.util import unquote
+from django.contrib.admin import helpers
+from django.contrib.admin.options import IncorrectLookupParameters
+from django.core.exceptions import PermissionDenied
+from django.utils.translation import ugettext as _
+from django.contrib.admin.util import quote
+from django.utils.encoding import force_unicode
+from django.utils.safestring import mark_safe
+from django.http import Http404, HttpResponseRedirect
+from django.utils.html import escape
+from django import forms, template
+
+from geoprisma_config.models import *
+from geoprisma_config.forms import *
+from utils import join_url
+
+from django.conf.urls.defaults import patterns
+
+# Inlines
+
+class ServiceOptionInline(admin.TabularInline):
+ form = ServiceOptionForm
+ model = ServiceOption
+ extra = 2
+
+class DatastoreOptionInline(admin.TabularInline):
+ form = DatastoreOptionForm
+ model = DatastoreOption
+ extra = 2
+
+class ResourceFieldInline(admin.TabularInline):
+ model = ResourceField
+ extra = 5
+
+class ResourceOptionInline(admin.TabularInline):
+ form = ResourceOptionForm
+ model = ResourceOption
+ extra = 5
+
+class FieldOptionInline(admin.TabularInline):
+ form = FieldOptionForm
+ model = FieldOption
+ extra = 5
+
+class AccessFilterOptionInline(admin.TabularInline):
+ form = AccessFilterOptionForm
+ model = AccessFilterOption
+ extra = 5
+
+class WidgetOptionInline(admin.TabularInline):
+ form = WidgetOptionForm
+ model = WidgetOption
+ extra = 5
+
+class MapContextOptionInline(admin.TabularInline):
+ form = MapContextOptionForm
+ model = MapContextOption
+ extra = 5
+
+class MapContextResourceInline(admin.TabularInline):
+ model = MapContextResource
+ extra = 5
+
+class ApplicationWidgetInline(admin.TabularInline):
+ model = ApplicationWidget
+ extra = 5
+
+# Admin Model
+
+class BaseModelAdmin(admin.ModelAdmin):
+
+ change_form_template = 'admin/change.html'
+
+ def get_urls(self):
+ urls = super(BaseModelAdmin, self).get_urls()
+ my_urls = patterns('',
+ ('^(?P<object_id>\d+)/$', self.changelist_changeform_view),
+ )
+ return my_urls + urls
+
+ def changelist_changeform_view(self, request, extra_context=None, add=False, object_id=None):
+ "The 'change list' and 'change form' admin view for BaseModelAdmin."
+ from django.contrib.admin.views.main import ChangeList, ERROR_FLAG
+ opts = self.model._meta
+ app_label = opts.app_label
+ if not self.has_change_permission(request, None):
+ raise PermissionDenied
+
+ # Fix links of save, save_continue form buttons
+ if not add and not object_id:
+ request.path += 'add/'
+
+ if '_popup' in request.REQUEST.keys():
+ return super(BaseModelAdmin, self).add_view(request)
+
+ # the form sender is either the changelist or the changeform
+ formSender = None
+ if '_formSender' in request.POST.keys():
+ formSender = request.POST['_formSender']
+
+ if request.method == 'POST' and formSender == 'changeform' and request.POST.has_key('_cancelgoback'):
+ return HttpResponseRedirect('../')
+
+ # Check actions to see if any are available on this changelist
+ actions = self.get_actions(request)
+
+ # Remove action checkboxes if there aren't any actions available.
+ list_display = list(self.list_display)
+ if not actions:
+ try:
+ list_display.remove('action_checkbox')
+ except ValueError:
+ pass
+
+ try:
+ cl = ChangeList(request, self.model, list_display, self.list_display_links, self.list_filter,
+ self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
+
+ except IncorrectLookupParameters:
+ # Wacky lookup parameters were given, so redirect to the main
+ # changelist page, without parameters, and pass an 'invalid=1'
+ # parameter via the query string. If wacky parameters were given and
+ # the 'invalid=1' parameter was already in the query string, something
+ # is screwed up with the database, so display an error page.
+ if ERROR_FLAG in request.GET.keys():
+ return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})
+ return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
+
+ # If the request was POSTed, this might be a bulk action or a bulk edit.
+ # Try to look up an action first, but if this isn't an action the POST
+ # will fall through to the bulk edit check, below.
+ if actions and request.method == 'POST' and formSender == 'changelist':
+ response = self.response_action(request, queryset=cl.get_query_set())
+ if response:
+ return response
+
+ # If we're allowing changelist editing, we need to construct a formset
+ # for the changelist given all the fields to be edited. Then we'll
+ # use the formset to validate/process POSTed data.
+ formset = cl.formset = None
+
+ # Handle POSTed bulk-edit data.
+ if request.method == "POST" and self.list_editable and formSender == 'changelist':
+ FormSet = self.get_changelist_formset(request)
+ formset = cl.formset = FormSet(request.POST, request.FILES, queryset=cl.result_list)
+ if formset.is_valid():
+ changecount = 0
+ for form in formset.forms:
+ if form.has_changed():
+ obj = self.save_form(request, form, change=True)
+ self.save_model(request, obj, form, change=True)
+ form.save_m2m()
+ change_msg = self.construct_change_message(request, form, None)
+ self.log_change(request, obj, change_msg)
+ changecount += 1
+
+ if changecount:
+ if changecount == 1:
+ name = force_unicode(opts.verbose_name)
+ else:
+ name = force_unicode(opts.verbose_name_plural)
+ msg = ungettext("%(count)s %(name)s was changed successfully.",
+ "%(count)s %(name)s were changed successfully.",
+ changecount) % {'count': changecount,
+ 'name': name,
+ 'obj': force_unicode(obj)}
+ self.message_user(request, msg)
+
+ return HttpResponseRedirect(request.get_full_path())
+
+ # Handle GET -- construct a formset for display.
+ elif self.list_editable:
+ FormSet = self.get_changelist_formset(request)
+ formset = cl.formset = FormSet(queryset=cl.result_list)
+
+ # Build the list of media to be used by the formset.
+ if formset:
+ media = self.media + formset.media
+ else:
+ media = self.media
+
+ # Build the action form and populate it with available actions.
+ if actions:
+ action_form = self.action_form(auto_id=None)
+ action_form.fields['action'].choices = self.get_action_choices(request)
+ else:
+ action_form = None
+
+ context = {
+ 'model_name': force_unicode(self.model._meta.verbose_name),
+ 'lc': {
+ 'title': cl.title,
+ 'cl': cl,
+ 'media': media,
+ 'root_path': self.admin_site.root_path,
+ 'app_label': app_label,
+ },
+ 'action_form': action_form,
+ 'actions_on_top': self.actions_on_top,
+ 'actions_on_bottom': self.actions_on_bottom,
+ 'is_popup': cl.is_popup,
+ 'has_add_permission': self.has_add_permission(request),
+ 'is_add': add,
+ 'object_id': object_id,
+ }
+ context.update(extra_context or {})
+
+ if object_id:
+ cl.url_for_result = lambda result, self=cl: "../%s/" % quote(getattr(result, self.pk_attname))
+ return super(BaseModelAdmin, self).change_view(request, object_id,
+ extra_context=context)
+ else:
+ if add:
+ cl.url_for_result = lambda result, self=cl: "../%s/" % quote(getattr(result, self.pk_attname))
+ else:
+ cl.url_for_result = lambda result, self=cl: "%s/" % quote(getattr(result, self.pk_attname))
+ return super(BaseModelAdmin, self).add_view(request, extra_context=context)
+
+
+ # Redirect standard views
+ def changelist_view(self, request, extra_context=None):
+ return self.changelist_changeform_view(request)
+
+ def change_view(self, request, object_id, extra_context=None):
+ return self.changelist_changeform_view(request)
+
+ def add_view(self, request, form_url='', extra_context=None):
+ return self.changelist_changeform_view(request, add=True)
+
+class ServiceAdmin(BaseModelAdmin):
+ form = ServiceForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (ServiceOptionInline,)
+
+class DatastoreAdmin(BaseModelAdmin):
+ form = DatastoreForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (DatastoreOptionInline,)
+
+
+class ResourceAdmin(BaseModelAdmin):
+ form = ResourceForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (ResourceOptionInline, ResourceFieldInline)
+ filter_horizontal = ('datastores',)
+
+ class Media:
+ js = (
+ join_url(settings.STATIC_URL,'gc_js/jquery-ui-1.8.2.custom.min.js'),
+ join_url(settings.STATIC_URL,'gc_js/admin-list-reorder.js'),
+ )
+
+class FieldAdmin(BaseModelAdmin):
+ form = FieldForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (FieldOptionInline,)
+
+class AccessFilterAdmin(BaseModelAdmin):
+ form = AccessFilterForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (AccessFilterOptionInline,)
+
+class WidgetAdmin(BaseModelAdmin):
+ form = WidgetForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (WidgetOptionInline,)
+
+ class Media:
+ js = (
+ join_url(settings.STATIC_URL,'gc_js/jquery-ui-1.8.2.custom.min.js'),
+ join_url(settings.STATIC_URL,'gc_js/admin-list-reorder.js'),
+ join_url(settings.STATIC_URL,'gc_js/admin-widgets.js'),
+ )
+
+class MapContextAdmin(BaseModelAdmin):
+ form = MapContextForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (MapContextOptionInline, MapContextResourceInline)
+
+ class Media:
+ js = (
+ join_url(settings.STATIC_URL,'gc_js/jquery-ui-1.8.2.custom.min.js'),
+ join_url(settings.STATIC_URL,'gc_js/admin-list-reorder.js'),
+ )
+
+class ApplicationAdmin(BaseModelAdmin):
+ form = ApplicationForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ inlines = (ApplicationWidgetInline,)
+
+ class Media:
+ js = (
+ join_url(settings.STATIC_URL,'gc_js/jquery-ui-1.8.2.custom.min.js'),
+ join_url(settings.STATIC_URL,'gc_js/admin-list-reorder.js'),
+ )
+
+class SessionAdmin(BaseModelAdmin):
+ form = SessionForm
+ list_display = ('name',)
+ search_fields = ('name',)
+ pass # do not remove this class
+
+admin.site.register(Datastore, DatastoreAdmin)
+admin.site.register(Service, ServiceAdmin)
+admin.site.register(Field, FieldAdmin)
+admin.site.register(AccessFilter, AccessFilterAdmin)
+admin.site.register(Resource, ResourceAdmin)
+admin.site.register(Widget, WidgetAdmin)
+admin.site.register(MapContext, MapContextAdmin)
+admin.site.register(Application, ApplicationAdmin)
+admin.site.register(Session, SessionAdmin)
No changes.
Oops, something went wrong.

0 comments on commit 7b87020

Please sign in to comment.