def signin(request, template_name='authopenid/signin.html', redirect_field_name=REDIRECT_FIELD_NAME, openid_form=OpenidSigninForm, auth_form=AuthenticationForm, on_failure=None, extra_context=None): """Signin page. It manage the legacy authentification (user/password) and authentification with openid. :attr request: request object :attr template_name: string, name of template to use :attr redirect_field_name: string, field name used for redirect. by default 'next' :attr openid_form: form use for openid signin, by default `OpenidSigninForm` :attr auth_form: form object used for legacy authentification. By default AuthentificationForm form auser auth contrib. :attr extra_context: A dictionary of variables to add to the template context. Any callable object in this dictionary will be called to produce the end result which appears in the context. """ if on_failure is None: on_failure = signin_failure from lingcod.common.utils import get_logger log = get_logger() redirect_to = request.REQUEST.get(redirect_field_name, '') form1 = openid_form() form2 = auth_form() log.debug(request.POST.keys()) if request.POST: if not redirect_to or '//' in redirect_to or ' ' in redirect_to: redirect_to = settings.LOGIN_REDIRECT_URL if 'openid_url' in request.POST.keys(): form1 = openid_form(data=request.POST) if form1.is_valid(): redirect_url = "%s%s?%s" % ( get_url_host(request), reverse('user_complete_signin'), urllib.urlencode({ redirect_field_name: redirect_to }) ) return ask_openid(request, form1.cleaned_data['openid_url'], redirect_url, on_failure=on_failure) else: # perform normal django authentification form2 = auth_form(data=request.POST) if form2.is_valid(): login(request, form2.get_user()) if request.session.test_cookie_worked(): request.session.delete_test_cookie() return HttpResponseRedirect(redirect_to) return render(template_name, { 'form1': form1, 'form2': form2, redirect_field_name: redirect_to, 'msg': request.GET.get('msg','') }, context_instance=_build_context(request, extra_context=extra_context))
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest, HttpResponseServerError, HttpResponseForbidden, Http404 from django.template import RequestContext from django.shortcuts import get_object_or_404, render_to_response from django.db import connection from lingcod.common import default_mimetypes as mimetypes from lingcod.common import utils from lingcod.staticmap.models import MapConfig from lingcod.features import get_feature_models, get_collection_models, get_feature_by_uid, get_model_by_uid from lingcod.features.models import FeatureCollection, SpatialFeature, PointFeature, PolygonFeature, LineFeature try: from djmapnik.adapter import PostgisLayer except: PostgisLayer = {} from lingcod.common.utils import get_logger from django.template.defaultfilters import slugify log = get_logger() try: settings_dbname = settings.DATABASES['default']['NAME'] except: settings_dbname = settings.DATABASE_NAME def default_style(): default_style = mapnik.Style() ps = mapnik.PolygonSymbolizer(mapnik.Color('#ffffff')) ps.fill_opacity = 0.5 ls = mapnik.LineSymbolizer(mapnik.Color('#555555'), 0.75) ls.stroke_opacity = 0.5 r = mapnik.Rule() r.symbols.append(ps)
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from lingcod.openid.utils.mimeparse import best_match from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from lingcod.openid.models import UserAssociation from lingcod.openid.views import xrdf from lingcod.common.utils import get_logger __all__ = ["OpenIDMiddleware"] log = get_logger() class OpenIDMiddleware(object): """ Populate request.openid. This comes either from cookie or from session, depending on the presence of OPENID_USE_SESSIONS. MP- HUH? I dont see that setting used anywhere """ def process_request(self, request): request.openid = request.session.get('openid', None) request.openids = request.session.get('openids', []) # The code below seems benign and perfectly understandable (just grabs the openids and attaches a list to the request object) # But for some unknown reason, this filter interacts with sessions in such a way that # load_sessions fails to work on requests from the GE plugin # # Not sure what the implications are for excluding it but we shall see
from django.db import models from django.conf import settings from django.contrib.auth.models import User, Group from lingcod.features.managers import ShareableGeoManager from lingcod.features.models import Feature, FeatureForm from lingcod.common.utils import get_logger from django.core.urlresolvers import reverse from django.utils.encoding import DjangoUnicodeDecodeError import os logger = get_logger() class UserUploadedKml(Feature): """ Abstract Model for storing uploaded restricted-access kml files Owned by a single user, can be shared with any group(s) that the owner is a member of (assuming group has can_share_features permissions) These are features and will show up in the MyShapes/SharedShapes panels """ kml_file = models.FileField(upload_to='upload/private-kml-layers/%Y/%m/%d', help_text=""" KML or KMZ file. Can use NetworkLinks pointing to remote kml datasets or WMS servers. """, blank=False, max_length=510) description = models.TextField(default="", null=True, blank=True) @property def basename(self): """ Name of the file itself without the path