app.utils

NotEqual

NotEqual(self, lhs, rhs)

Allow lookup and exclusion using not equal.

lookup_name

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

as_sql

NotEqual.as_sql(self, compiler, connection)

Handle as SQL method for not equal lookup.

get_query_cache_key

get_query_cache_key(compiler)

Generate a cache key from a SQLCompiler.

This cache key is specific to the SQL query and its context (which database is used). The same query in the same context (= the same database) must generate the same cache key.

Args: compiler (django.db.models.sql.compiler.SQLCompiler): A SQLCompiler that will generate the SQL query.

Returns: int: The cache key.

get_table_cache_key

get_table_cache_key(db_alias, table)

Generates a cache key from a SQL table.

Args: db_alias (str): The alias of the used database. table (str): The name of the SQL table.

Returns: int: The cache key.

get_raw_cache_client

get_raw_cache_client(backend='default')

Get a raw Redis cache client connection.

Args: backend (str): The backend to attempt connection against.

Raises: Exception: The exception is raised/caught if any generic exception is encountered during the connection attempt.

Returns: redis.client.StrictRedis: The raw Redis client connection. If an exception is encountered, return None.

add_contributors

add_contributors(repo_data)

Add contributor data to repository data dictionary.

Args: repo_data (dict): The repository data dictionary to be updated.

Returns: dict: The updated repository data dictionary.

setup_lang

setup_lang(request, user)

Handle setting the user's language preferences and store in the session.

Args: request (Request): The Django request object. user (User): The Django user object.

Raises: DoesNotExist: The exception is raised if no profile is found for the specified handle.

handle_location_request

handle_location_request(request)

Handle determining location data from request IP.

get_location_from_ip

get_location_from_ip(ip_address)

Get the location associated with the provided IP address.

Args: ip_address (str): The IP address to lookup.

Returns: dict: The GeoIP location data dictionary.

get_country_from_ip

get_country_from_ip(ip_address, db=None)

Get the user's country information from the provided IP address.

clean_str

clean_str(string)

Clean the provided string of all non-alpha numeric characters.