SEED Package¶
Subpackages¶
Inheritance¶
Submodules¶
Decorators¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
- seed.decorators.DecoratorMixin(decorator)¶
Converts a decorator written for a function view into a mixin for a class-based view.
Example:
LoginRequiredMixin = DecoratorMixin(login_required) class MyView(LoginRequiredMixin): pass class SomeView(DecoratorMixin(some_decorator), DecoratorMixin(something_else)): pass
- seed.decorators.ajax_request(func)¶
Copied from django-annoying, with a small modification. Now we also check for ‘status’ or ‘success’ keys and slash return correct status codes
If view returned serializable dict, returns response in a format requested by HTTP_ACCEPT header. Defaults to JSON if none requested or match.
Currently supports JSON or YAML (if installed), but can easily be extended.
Example:
@ajax_request def my_view(request): news = News.objects.all() news_titles = [entry.title for entry in news] return { 'news_titles': news_titles }
- seed.decorators.ajax_request_class(func)¶
Copied from django-annoying, with a small modification. Now we also check for ‘status’ or
‘success’ keys and return correct status codes
If view returned serializable dict, returns response in a format requested by HTTP_ACCEPT header. Defaults to JSON if none requested or match.
Currently supports JSON or YAML (if installed), but can easily be extended.
Example:
@ajax_request def my_view(self, request): news = News.objects.all() news_titles = [entry.title for entry in news] return { 'news_titles': news_titles }
- seed.decorators.get_prog_key(func_name, import_file_pk)¶
Return the progress key for the cache
- seed.decorators.lock_and_track(fn, *args, **kwargs)¶
Decorator to lock tasks to single executor and provide progress url.
- seed.decorators.require_organization_id(func)¶
Validate that organization_id is in the GET params and it’s an int.
- seed.decorators.require_organization_id_class(fn)¶
Validate that organization_id is in the GET params and it’s an int.
- seed.decorators.require_organization_membership(fn)¶
Validate that the organization_id passed in GET is valid for request user.
Factory¶
Models¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
Search¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
Search methods pertaining to buildings.
returns a list of sibling and parent orgs
- seed.search.create_inventory_queryset(inventory_type, orgs, exclude, order_by, other_orgs=None, cycle_id=None)¶
creates a queryset of properties or taxlots within orgs. If
other_orgs
, properties/taxlots in both orgs and other_orgs will be represented in the queryset.- Parameters
inventory_type – property or taxlot.
orgs – queryset of Organization inst.
exclude – django query exclude dict.
order_by – django query order_by str.
other_orgs – list of other orgs to
or
the query
- seed.search.get_inventory_fieldnames(inventory_type)¶
returns a list of field names that will be searched against
- seed.search.get_orgs_w_public_fields()¶
returns a list of orgs that have publicly shared fields
- seed.search.inventory_search_filter_sort(inventory_type, params, user, cycle_id=None)¶
Given a parsed set of params, perform the search, filter, and sort for Properties or Taxlots
- seed.search.parse_body(request)¶
parses the request body for search params, q, etc
- Parameters
request – django wsgi request object
- Returns
dict
Example:
{ 'exclude': dict, exclude dict for django queryset 'order_by': str, query order_by, defaults to 'tax_lot_id' 'sort_reverse': bool, True if ASC, False if DSC 'page': int, pagination page 'number_per_page': int, number per pagination page 'show_shared_buildings': bool, whether to search across all user's orgs 'q': str, global search param 'other_search_params': dict, filter params 'project_id': str, project id if exists in body }
- seed.search.process_search_params(params, user, is_api_request=False)¶
Given a python representation of a search query, process it into the internal format that is used for searching, filtering, sorting, and pagination.
- Parameters
params – a python object representing the search query
user – the user this search is for
is_api_request – bool, boolean whether this search is being done as an api request.
- Returns
dict
Example:
{ 'exclude': dict, exclude dict for django queryset 'order_by': str, query order_by, defaults to 'tax_lot_id' 'sort_reverse': bool, True if ASC, False if DSC 'page': int, pagination page 'number_per_page': int, number per pagination page 'show_shared_buildings': bool, whether to search across all user's orgs 'q': str, global search param 'other_search_params': dict, filter params 'project_id': str, project id if exists in body }
- seed.search.search_inventory(inventory_type, q, fieldnames=None, queryset=None)¶
returns a queryset for matching Taxlot(View)/Property(View) :param str or unicode q: search string :param list fieldnames: list of model fieldnames :param queryset: optional queryset to filter from :returns: :queryset: queryset of matching buildings
- seed.search.search_properties(q, fieldnames=None, queryset=None)¶
- seed.search.search_taxlots(q, fieldnames=None, queryset=None)¶
Tasks¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
- seed.tasks.delete_organization(org_pk)¶
delete_organization_buildings
- seed.tasks.invite_new_user_to_seed(domain, email_address, token, user_pk, first_name)¶
Send invitation email to newly created user from the landing page. NOTE: this function is only used on the landing page because the user has not been assigned an organization domain – The domain name of the running seed instance email_address – The address to send the invitation to token – generated by Django’s default_token_generator user_pk – primary key for this user record first_name – First name of the new user new_user
Returns: nothing
- seed.tasks.send_salesforce_error_log(org_pk, errors)¶
send salesforce error log to logging email when errors are encountered during scheduled sync
Token Generator¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
- author
Aleck Landgraf
token_generator.py - taken from django core master branch
needed a token check that would not expire after three days for sending a signup email
- class seed.token_generators.SignupTokenGenerator¶
Bases:
object
Strategy object used to generate and check tokens for the password reset mechanism.
- check_token(user, token, token_expires=True)¶
Check that a password reset token is correct for a given user.
- make_token(user)¶
Returns a token that can be used once to do a password reset for the given user.
URLs¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
Utils¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
Views¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md
Module contents¶
SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. See also https://github.com/seed-platform/seed/main/LICENSE.md