コード例 #1
0
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)
コード例 #2
0
ファイル: middleware.py プロジェクト: Phantazm/django-ip2geo
    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
コード例 #3
0
ファイル: middleware.py プロジェクト: Abdienoor/idl-members
    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
コード例 #4
0
    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
コード例 #5
0
    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
コード例 #6
0
    """

    # 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',]
コード例 #7
0
    """

    # 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',]
コード例 #8
0
ファイル: middleware.py プロジェクト: Phantazm/django-ip2geo
    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',]
    
コード例 #9
0
ファイル: models.py プロジェクト: Verurteilt/dentalpharmakids
 def __unicode__(self):
     return _(self.nombre)
コード例 #10
0
ファイル: models.py プロジェクト: Verurteilt/dentalpharmakids
 def get_short_name(self):
     return _(self.nombre)
コード例 #11
0
ファイル: models.py プロジェクト: Verurteilt/dentalpharmakids
 def get_full_name(self):
     return _(self.nombre)
コード例 #12
0
ファイル: middleware.py プロジェクト: Abdienoor/idl-members
    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',]
    
コード例 #13
0
 def __unicode__(self):
     return _(self.username)
コード例 #14
0
 def get_short_name(self):
     return _(self.first_name)
コード例 #15
0
 def get_full_name(self):
     return _(self.first_name) + ' ' + _(self.last_name)