def send_request_email(instance): domain = settings.DOMAIN + reverse('pass change prep', kwargs={ "slug": _(instance.slug), "code": _(set_key(instance)) }) name = '' if instance.is_athlete: name = instance.athlete.__str__ elif instance.is_referee: name = instance.referee.__str__ elif 'admin' or 'staff' in instance.slug: name = instance.slug[6:] name = name[0].upper() + name[1:] context = {'name': name, 'domain': domain} plain = render_to_string('registration/password_change_request_email.html', context) print(plain)
def process_view(self, request, view_func, *view_args, **view_kwargs): if not 'geoip' in request.session: try: ip = get_ip(request) # if settings.DEBUG: # print('current ip: %s' % (ip,)) record = self.gip.record_by_addr(ip) for field in settings.GEOIP_SESSION_FIELDS: try: request.session[field] = _(record[field], encoding='iso8859-1', strings_only=False) except: request.session[field] = GEOIP_UNKNOWN except Exception, e: for field in settings.GEOIP_SESSION_FIELDS: request.session[field] = GEOIP_UNKNOWN # if settings.DEBUG: # print(str(e)) request.session['geoip'] = True
def process_view(self, request, view_func, *view_args, **view_kwargs): if not 'geoip' in request.session: try: ip = get_ip(request) # For local testing if ip in ['127.0.0.1', '10.0.1.3']: ip = '115.187.74.78' record = self.gip.record_by_addr(ip) for field in settings.GEOIP_SESSION_FIELDS: try: request.session[field] = _(record[field], encoding='iso8859-1', strings_only=False) except: request.session[field] = GEOIP_UNKNOWN except Exception, e: for field in settings.GEOIP_SESSION_FIELDS: request.session[field] = GEOIP_UNKNOWN request.session['geoip'] = True
""" # if neither header contain a value, just use local loopback ip_address = request.META.get('HTTP_X_FORWARDED_FOR', request.META.get('REMOTE_ADDR', '127.0.0.1')) if ip_address: # make sure we have one and only one IP try: ip_address = IP_RE.match(ip_address).group(0) except IndexError: pass return ip_address GEOIP_UNKNOWN = _('') class CityMiddleware(object): """ More information about Python-MaxMind: http://code.google.com/p/pygeoip/ In settings.py: GEOIP_DATA = '/path/to/GeoLiteCity.dat' You can choose the following fields that will be stored in the session: GEOIP_SESSION_FIELDS = ['country_name', 'country_code', 'country_code3', 'region_name', 'city', 'latitude', 'longitude', 'postal_code'] You do not have to select all of them, for example: GEOIP_SESSION_FIELDS = ['country_name', 'region_name', 'city',]
""" # if neither header contain a value, just use local loopback ip_address = request.META.get('HTTP_X_FORWARDED_FOR', request.META.get('REMOTE_ADDR', '127.0.0.1')) if ip_address: # make sure we have one and only one IP try: ip_address = IP_RE.match(ip_address).group(0) except IndexError: pass return ip_address GEOIP_UNKNOWN = _('---') class CityMiddleware(object): """ More information about Python-MaxMind: http://code.google.com/p/pygeoip/ In settings.py: GEOIP_DATA = '/path/to/GeoLiteCity.dat' You can choose the following fields that will be stored in the session: GEOIP_SESSION_FIELDS = ['country_name', 'country_code', 'country_code3', 'region_name', 'city', 'latitude', 'longitude', 'postal_code'] You do not have to select all of them, for example: GEOIP_SESSION_FIELDS = ['country_name', 'region_name', 'city',]
IP from the proper place. """ # if neither header contain a value, just use local loopback ip_address = request.META.get('HTTP_X_FORWARDED_FOR', request.META.get('REMOTE_ADDR', '127.0.0.1')) if ip_address: # make sure we have one and only one IP try: ip_address = IP_RE.match(ip_address).group(0) except IndexError: pass return ip_address GEOIP_UNKNOWN = _('---') class CityMiddleware(object): """ More information about Python-MaxMind: http://code.google.com/p/pygeoip/ In settings.py: GEOIP_DATA = '/path/to/GeoLiteCity.dat' You can choose the following fields that will be stored in the session: GEOIP_SESSION_FIELDS = ['country_name', 'country_code', 'country_code3', 'region_name', 'city', 'latitude', 'longitude', 'postal_code'] You do not have to select all of them, for example: GEOIP_SESSION_FIELDS = ['country_name', 'region_name', 'city',]
def __unicode__(self): return _(self.nombre)
def get_short_name(self): return _(self.nombre)
def get_full_name(self): return _(self.nombre)
IP from the proper place. """ # if neither header contain a value, just use local loopback ip_address = request.META.get('HTTP_X_FORWARDED_FOR', request.META.get('REMOTE_ADDR', '127.0.0.1')) if ip_address: # make sure we have one and only one IP try: ip_address = IP_RE.match(ip_address).group(0) except IndexError: pass return ip_address GEOIP_UNKNOWN = _('') class CityMiddleware(object): """ More information about Python-MaxMind: http://code.google.com/p/pygeoip/ In settings.py: GEOIP_DATA = '/path/to/GeoLiteCity.dat' You can choose the following fields that will be stored in the session: GEOIP_SESSION_FIELDS = ['country_name', 'country_code', 'country_code3', 'region_name', 'city', 'latitude', 'longitude', 'postal_code'] You do not have to select all of them, for example: GEOIP_SESSION_FIELDS = ['country_name', 'region_name', 'city',]
def __unicode__(self): return _(self.username)
def get_short_name(self): return _(self.first_name)
def get_full_name(self): return _(self.first_name) + ' ' + _(self.last_name)