partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
VcfRecord.text
Returns tab-delimited, newline terminated string of VcfRecord.
jacquard/utils/vcf.py
def text(self): "Returns tab-delimited, newline terminated string of VcfRecord." stringifier = [self.chrom, self.pos, self.vcf_id, self.ref, self.alt, self.qual, self.filter, self.info, self._format_field()] for sample in self.sample_tag_values: ...
def text(self): "Returns tab-delimited, newline terminated string of VcfRecord." stringifier = [self.chrom, self.pos, self.vcf_id, self.ref, self.alt, self.qual, self.filter, self.info, self._format_field()] for sample in self.sample_tag_values: ...
[ "Returns", "tab", "-", "delimited", "newline", "terminated", "string", "of", "VcfRecord", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L357-L366
[ "def", "text", "(", "self", ")", ":", "stringifier", "=", "[", "self", ".", "chrom", ",", "self", ".", "pos", ",", "self", ".", "vcf_id", ",", "self", ".", "ref", ",", "self", ".", "alt", ",", "self", ".", "qual", ",", "self", ".", "filter", ",...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord.add_sample_tag_value
Appends a new format tag-value for all samples. Args: tag_name: string tag name; must not already exist new_sample Raises: KeyError: if tag_name to be added already exists
jacquard/utils/vcf.py
def add_sample_tag_value(self, tag_name, new_sample_values): """Appends a new format tag-value for all samples. Args: tag_name: string tag name; must not already exist new_sample Raises: KeyError: if tag_name to be added already exists """ if...
def add_sample_tag_value(self, tag_name, new_sample_values): """Appends a new format tag-value for all samples. Args: tag_name: string tag name; must not already exist new_sample Raises: KeyError: if tag_name to be added already exists """ if...
[ "Appends", "a", "new", "format", "tag", "-", "value", "for", "all", "samples", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L372-L391
[ "def", "add_sample_tag_value", "(", "self", ",", "tag_name", ",", "new_sample_values", ")", ":", "if", "tag_name", "in", "self", ".", "format_tags", ":", "msg", "=", "\"New format value [{}] already exists.\"", ".", "format", "(", "tag_name", ")", "raise", "KeyErr...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
VcfRecord.add_or_replace_filter
Replaces null or blank filter or adds filter to existing list.
jacquard/utils/vcf.py
def add_or_replace_filter(self, new_filter): """Replaces null or blank filter or adds filter to existing list.""" if self.filter.lower() in self._FILTERS_TO_REPLACE: self.filter = new_filter elif new_filter not in self.filter.split(";"): self.filter = ";".join([self.filte...
def add_or_replace_filter(self, new_filter): """Replaces null or blank filter or adds filter to existing list.""" if self.filter.lower() in self._FILTERS_TO_REPLACE: self.filter = new_filter elif new_filter not in self.filter.split(";"): self.filter = ";".join([self.filte...
[ "Replaces", "null", "or", "blank", "filter", "or", "adds", "filter", "to", "existing", "list", "." ]
umich-brcf-bioinf/Jacquard
python
https://github.com/umich-brcf-bioinf/Jacquard/blob/83dd61dd2b5e4110468493beec7bc121e6cb3cd1/jacquard/utils/vcf.py#L393-L399
[ "def", "add_or_replace_filter", "(", "self", ",", "new_filter", ")", ":", "if", "self", ".", "filter", ".", "lower", "(", ")", "in", "self", ".", "_FILTERS_TO_REPLACE", ":", "self", ".", "filter", "=", "new_filter", "elif", "new_filter", "not", "in", "self...
83dd61dd2b5e4110468493beec7bc121e6cb3cd1
test
CategoryController.available_categories
Returns the categories available to the user. Specify `products` if you want to restrict to just the categories that hold the specified products, otherwise it'll do all.
registrasion/controllers/category.py
def available_categories(cls, user, products=AllProducts): ''' Returns the categories available to the user. Specify `products` if you want to restrict to just the categories that hold the specified products, otherwise it'll do all. ''' # STOPGAP -- this needs to be elsewhere tbqh ...
def available_categories(cls, user, products=AllProducts): ''' Returns the categories available to the user. Specify `products` if you want to restrict to just the categories that hold the specified products, otherwise it'll do all. ''' # STOPGAP -- this needs to be elsewhere tbqh ...
[ "Returns", "the", "categories", "available", "to", "the", "user", ".", "Specify", "products", "if", "you", "want", "to", "restrict", "to", "just", "the", "categories", "that", "hold", "the", "specified", "products", "otherwise", "it", "ll", "do", "all", "." ...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/category.py#L25-L43
[ "def", "available_categories", "(", "cls", ",", "user", ",", "products", "=", "AllProducts", ")", ":", "# STOPGAP -- this needs to be elsewhere tbqh", "from", ".", "product", "import", "ProductController", "if", "products", "is", "AllProducts", ":", "products", "=", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ProductsForm
Produces an appropriate _ProductsForm subclass for the given render type.
registrasion/forms.py
def ProductsForm(category, products): ''' Produces an appropriate _ProductsForm subclass for the given render type. ''' # Each Category.RENDER_TYPE value has a subclass here. cat = inventory.Category RENDER_TYPES = { cat.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, cat.RENDER_TYP...
def ProductsForm(category, products): ''' Produces an appropriate _ProductsForm subclass for the given render type. ''' # Each Category.RENDER_TYPE value has a subclass here. cat = inventory.Category RENDER_TYPES = { cat.RENDER_TYPE_QUANTITY: _QuantityBoxProductsForm, cat.RENDER_TYP...
[ "Produces", "an", "appropriate", "_ProductsForm", "subclass", "for", "the", "given", "render", "type", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/forms.py#L88-L116
[ "def", "ProductsForm", "(", "category", ",", "products", ")", ":", "# Each Category.RENDER_TYPE value has a subclass here.", "cat", "=", "inventory", ".", "Category", "RENDER_TYPES", "=", "{", "cat", ".", "RENDER_TYPE_QUANTITY", ":", "_QuantityBoxProductsForm", ",", "ca...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
staff_products_form_factory
Creates a StaffProductsForm that restricts the available products to those that are available to a user.
registrasion/forms.py
def staff_products_form_factory(user): ''' Creates a StaffProductsForm that restricts the available products to those that are available to a user. ''' products = inventory.Product.objects.all() products = ProductController.available_products(user, products=products) product_ids = [product.id for ...
def staff_products_form_factory(user): ''' Creates a StaffProductsForm that restricts the available products to those that are available to a user. ''' products = inventory.Product.objects.all() products = ProductController.available_products(user, products=products) product_ids = [product.id for ...
[ "Creates", "a", "StaffProductsForm", "that", "restricts", "the", "available", "products", "to", "those", "that", "are", "available", "to", "a", "user", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/forms.py#L437-L459
[ "def", "staff_products_form_factory", "(", "user", ")", ":", "products", "=", "inventory", ".", "Product", ".", "objects", ".", "all", "(", ")", "products", "=", "ProductController", ".", "available_products", "(", "user", ",", "products", "=", "products", ")"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_HasProductsFields.add_product_error
Adds an error to the given product's field
registrasion/forms.py
def add_product_error(self, product, error): ''' Adds an error to the given product's field ''' ''' if product in field_names: field = field_names[product] elif isinstance(product, inventory.Product): return else: field = None ''' self.add_er...
def add_product_error(self, product, error): ''' Adds an error to the given product's field ''' ''' if product in field_names: field = field_names[product] elif isinstance(product, inventory.Product): return else: field = None ''' self.add_er...
[ "Adds", "an", "error", "to", "the", "given", "product", "s", "field" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/forms.py#L152-L162
[ "def", "add_product_error", "(", "self", ",", "product", ",", "error", ")", ":", "''' if product in field_names:\n field = field_names[product]\n elif isinstance(product, inventory.Product):\n return\n else:\n field = None '''", "self", ".", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_ItemQuantityProductsFormSet.initial_data
Prepares initial data for an instance of this form. product_quantities is a sequence of (product,quantity) tuples
registrasion/forms.py
def initial_data(cls, product_quantities): ''' Prepares initial data for an instance of this form. product_quantities is a sequence of (product,quantity) tuples ''' f = [ { _ItemQuantityProductsForm.CHOICE_FIELD: product.id, _ItemQuantityProductsForm....
def initial_data(cls, product_quantities): ''' Prepares initial data for an instance of this form. product_quantities is a sequence of (product,quantity) tuples ''' f = [ { _ItemQuantityProductsForm.CHOICE_FIELD: product.id, _ItemQuantityProductsForm....
[ "Prepares", "initial", "data", "for", "an", "instance", "of", "this", "form", ".", "product_quantities", "is", "a", "sequence", "of", "(", "product", "quantity", ")", "tuples" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/forms.py#L367-L379
[ "def", "initial_data", "(", "cls", ",", "product_quantities", ")", ":", "f", "=", "[", "{", "_ItemQuantityProductsForm", ".", "CHOICE_FIELD", ":", "product", ".", "id", ",", "_ItemQuantityProductsForm", ".", "QUANTITY_FIELD", ":", "quantity", ",", "}", "for", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_ItemQuantityProductsFormSet.product_quantities
Yields a sequence of (product, quantity) tuples from the cleaned form data.
registrasion/forms.py
def product_quantities(self): ''' Yields a sequence of (product, quantity) tuples from the cleaned form data. ''' products = set() # Track everything so that we can yield some zeroes all_products = set() for form in self: if form.empty_permitted and not form...
def product_quantities(self): ''' Yields a sequence of (product, quantity) tuples from the cleaned form data. ''' products = set() # Track everything so that we can yield some zeroes all_products = set() for form in self: if form.empty_permitted and not form...
[ "Yields", "a", "sequence", "of", "(", "product", "quantity", ")", "tuples", "from", "the", "cleaned", "form", "data", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/forms.py#L381-L411
[ "def", "product_quantities", "(", "self", ")", ":", "products", "=", "set", "(", ")", "# Track everything so that we can yield some zeroes", "all_products", "=", "set", "(", ")", "for", "form", "in", "self", ":", "if", "form", ".", "empty_permitted", "and", "not...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
BatchController.memoise
Decorator that stores the result of the stored function in the user's results cache until the batch completes. Keyword arguments are not yet supported. Arguments: func (callable(*a)): The function whose results we want to store. The positional arguments, ``a``, are u...
registrasion/controllers/batch.py
def memoise(cls, func): ''' Decorator that stores the result of the stored function in the user's results cache until the batch completes. Keyword arguments are not yet supported. Arguments: func (callable(*a)): The function whose results we want to store. Th...
def memoise(cls, func): ''' Decorator that stores the result of the stored function in the user's results cache until the batch completes. Keyword arguments are not yet supported. Arguments: func (callable(*a)): The function whose results we want to store. Th...
[ "Decorator", "that", "stores", "the", "result", "of", "the", "stored", "function", "in", "the", "user", "s", "results", "cache", "until", "the", "batch", "completes", ".", "Keyword", "arguments", "are", "not", "yet", "supported", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/batch.py#L71-L104
[ "def", "memoise", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "f", "(", "*", "a", ")", ":", "for", "arg", "in", "a", ":", "if", "isinstance", "(", "arg", ",", "User", ")", ":", "user", "=", "arg...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
model_fields_form_factory
Creates a form for specifying fields from a model to display.
registrasion/reporting/forms.py
def model_fields_form_factory(model): ''' Creates a form for specifying fields from a model to display. ''' fields = model._meta.get_fields() choices = [] for field in fields: if hasattr(field, "verbose_name"): choices.append((field.name, field.verbose_name)) class ModelFields...
def model_fields_form_factory(model): ''' Creates a form for specifying fields from a model to display. ''' fields = model._meta.get_fields() choices = [] for field in fields: if hasattr(field, "verbose_name"): choices.append((field.name, field.verbose_name)) class ModelFields...
[ "Creates", "a", "form", "for", "specifying", "fields", "from", "a", "model", "to", "display", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/forms.py#L81-L97
[ "def", "model_fields_form_factory", "(", "model", ")", ":", "fields", "=", "model", ".", "_meta", ".", "get_fields", "(", ")", "choices", "=", "[", "]", "for", "field", "in", "fields", ":", "if", "hasattr", "(", "field", ",", "\"verbose_name\"", ")", ":"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ItemController._items
Aggregates the items that this user has purchased. Arguments: cart_status (int or Iterable(int)): etc category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: [ProductAndQuantity, ...]: A list of product-quantity...
registrasion/controllers/item.py
def _items(self, cart_status, category=None): ''' Aggregates the items that this user has purchased. Arguments: cart_status (int or Iterable(int)): etc category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: ...
def _items(self, cart_status, category=None): ''' Aggregates the items that this user has purchased. Arguments: cart_status (int or Iterable(int)): etc category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: ...
[ "Aggregates", "the", "items", "that", "this", "user", "has", "purchased", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/item.py#L37-L83
[ "def", "_items", "(", "self", ",", "cart_status", ",", "category", "=", "None", ")", ":", "if", "not", "isinstance", "(", "cart_status", ",", "Iterable", ")", ":", "cart_status", "=", "[", "cart_status", "]", "status_query", "=", "(", "Q", "(", "producti...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ItemController.items_pending_or_purchased
Returns the items that this user has purchased or has pending.
registrasion/controllers/item.py
def items_pending_or_purchased(self): ''' Returns the items that this user has purchased or has pending. ''' status = [commerce.Cart.STATUS_PAID, commerce.Cart.STATUS_ACTIVE] return self._items(status)
def items_pending_or_purchased(self): ''' Returns the items that this user has purchased or has pending. ''' status = [commerce.Cart.STATUS_PAID, commerce.Cart.STATUS_ACTIVE] return self._items(status)
[ "Returns", "the", "items", "that", "this", "user", "has", "purchased", "or", "has", "pending", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/item.py#L85-L88
[ "def", "items_pending_or_purchased", "(", "self", ")", ":", "status", "=", "[", "commerce", ".", "Cart", ".", "STATUS_PAID", ",", "commerce", ".", "Cart", ".", "STATUS_ACTIVE", "]", "return", "self", ".", "_items", "(", "status", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ItemController.items_purchased
Aggregates the items that this user has purchased. Arguments: category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: [ProductAndQuantity, ...]: A list of product-quantity pairs, aggregating like products fr...
registrasion/controllers/item.py
def items_purchased(self, category=None): ''' Aggregates the items that this user has purchased. Arguments: category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: [ProductAndQuantity, ...]: A list of product-quanti...
def items_purchased(self, category=None): ''' Aggregates the items that this user has purchased. Arguments: category (Optional[models.inventory.Category]): the category of items to restrict to. Returns: [ProductAndQuantity, ...]: A list of product-quanti...
[ "Aggregates", "the", "items", "that", "this", "user", "has", "purchased", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/item.py#L90-L102
[ "def", "items_purchased", "(", "self", ",", "category", "=", "None", ")", ":", "return", "self", ".", "_items", "(", "commerce", ".", "Cart", ".", "STATUS_PAID", ",", "category", "=", "category", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
Sender.send_email
Sends an e-mail to the given address. to: The address kind: the ID for an e-mail kind; it should point to a subdirectory of self.template_prefix containing subject.txt and message.html, which are django templates for the subject and HTML message respectively. context: a...
registrasion/contrib/mail.py
def send_email(self, to, kind, **kwargs): ''' Sends an e-mail to the given address. to: The address kind: the ID for an e-mail kind; it should point to a subdirectory of self.template_prefix containing subject.txt and message.html, which are django templates for the subj...
def send_email(self, to, kind, **kwargs): ''' Sends an e-mail to the given address. to: The address kind: the ID for an e-mail kind; it should point to a subdirectory of self.template_prefix containing subject.txt and message.html, which are django templates for the subj...
[ "Sends", "an", "e", "-", "mail", "to", "the", "given", "address", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/contrib/mail.py#L17-L29
[ "def", "send_email", "(", "self", ",", "to", ",", "kind", ",", "*", "*", "kwargs", ")", ":", "return", "__send_email__", "(", "self", ".", "template_prefix", ",", "to", ",", "kind", ",", "*", "*", "kwargs", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
iter_changeset_stream
Start processing an OSM changeset stream and yield one (action, primitive) tuple at a time to the caller.
pyosm/parsing.py
def iter_changeset_stream(start_sqn=None, base_url='https://planet.openstreetmap.org/replication/changesets', expected_interval=60, parse_timestamps=True, state_dir=None): """Start processing an OSM changeset stream and yield one (action, primitive) tuple at a time to the caller.""" # This is a lot like th...
def iter_changeset_stream(start_sqn=None, base_url='https://planet.openstreetmap.org/replication/changesets', expected_interval=60, parse_timestamps=True, state_dir=None): """Start processing an OSM changeset stream and yield one (action, primitive) tuple at a time to the caller.""" # This is a lot like th...
[ "Start", "processing", "an", "OSM", "changeset", "stream", "and", "yield", "one", "(", "action", "primitive", ")", "tuple", "at", "a", "time", "to", "the", "caller", "." ]
iandees/pyosm
python
https://github.com/iandees/pyosm/blob/532dffceae91e2bce89c530ceff627bc8210f8aa/pyosm/parsing.py#L53-L133
[ "def", "iter_changeset_stream", "(", "start_sqn", "=", "None", ",", "base_url", "=", "'https://planet.openstreetmap.org/replication/changesets'", ",", "expected_interval", "=", "60", ",", "parse_timestamps", "=", "True", ",", "state_dir", "=", "None", ")", ":", "# Thi...
532dffceae91e2bce89c530ceff627bc8210f8aa
test
iter_osm_stream
Start processing an OSM diff stream and yield one changeset at a time to the caller.
pyosm/parsing.py
def iter_osm_stream(start_sqn=None, base_url='https://planet.openstreetmap.org/replication/minute', expected_interval=60, parse_timestamps=True, state_dir=None): """Start processing an OSM diff stream and yield one changeset at a time to the caller.""" # If the user specifies a state_dir, read the state fr...
def iter_osm_stream(start_sqn=None, base_url='https://planet.openstreetmap.org/replication/minute', expected_interval=60, parse_timestamps=True, state_dir=None): """Start processing an OSM diff stream and yield one changeset at a time to the caller.""" # If the user specifies a state_dir, read the state fr...
[ "Start", "processing", "an", "OSM", "diff", "stream", "and", "yield", "one", "changeset", "at", "a", "time", "to", "the", "caller", "." ]
iandees/pyosm
python
https://github.com/iandees/pyosm/blob/532dffceae91e2bce89c530ceff627bc8210f8aa/pyosm/parsing.py#L213-L280
[ "def", "iter_osm_stream", "(", "start_sqn", "=", "None", ",", "base_url", "=", "'https://planet.openstreetmap.org/replication/minute'", ",", "expected_interval", "=", "60", ",", "parse_timestamps", "=", "True", ",", "state_dir", "=", "None", ")", ":", "# If the user s...
532dffceae91e2bce89c530ceff627bc8210f8aa
test
parse_osm_file
Parse a file-like containing OSM XML into memory and return an object with the nodes, ways, and relations it contains.
pyosm/parsing.py
def parse_osm_file(f, parse_timestamps=True): """Parse a file-like containing OSM XML into memory and return an object with the nodes, ways, and relations it contains. """ nodes = [] ways = [] relations = [] for p in iter_osm_file(f, parse_timestamps): if type(p) == model.Node: ...
def parse_osm_file(f, parse_timestamps=True): """Parse a file-like containing OSM XML into memory and return an object with the nodes, ways, and relations it contains. """ nodes = [] ways = [] relations = [] for p in iter_osm_file(f, parse_timestamps): if type(p) == model.Node: ...
[ "Parse", "a", "file", "-", "like", "containing", "OSM", "XML", "into", "memory", "and", "return", "an", "object", "with", "the", "nodes", "ways", "and", "relations", "it", "contains", "." ]
iandees/pyosm
python
https://github.com/iandees/pyosm/blob/532dffceae91e2bce89c530ceff627bc8210f8aa/pyosm/parsing.py#L375-L392
[ "def", "parse_osm_file", "(", "f", ",", "parse_timestamps", "=", "True", ")", ":", "nodes", "=", "[", "]", "ways", "=", "[", "]", "relations", "=", "[", "]", "for", "p", "in", "iter_osm_file", "(", "f", ",", "parse_timestamps", ")", ":", "if", "type"...
532dffceae91e2bce89c530ceff627bc8210f8aa
test
iter_osm_notes
Parses the global OSM Notes feed and yields as much Note information as possible.
pyosm/parsing.py
def iter_osm_notes(feed_limit=25, interval=60, parse_timestamps=True): """ Parses the global OSM Notes feed and yields as much Note information as possible. """ last_seen_guid = None while True: u = urllib2.urlopen('https://www.openstreetmap.org/api/0.6/notes/feed?limit=%d' % feed_limit) t...
def iter_osm_notes(feed_limit=25, interval=60, parse_timestamps=True): """ Parses the global OSM Notes feed and yields as much Note information as possible. """ last_seen_guid = None while True: u = urllib2.urlopen('https://www.openstreetmap.org/api/0.6/notes/feed?limit=%d' % feed_limit) t...
[ "Parses", "the", "global", "OSM", "Notes", "feed", "and", "yields", "as", "much", "Note", "information", "as", "possible", "." ]
iandees/pyosm
python
https://github.com/iandees/pyosm/blob/532dffceae91e2bce89c530ceff627bc8210f8aa/pyosm/parsing.py#L426-L466
[ "def", "iter_osm_notes", "(", "feed_limit", "=", "25", ",", "interval", "=", "60", ",", "parse_timestamps", "=", "True", ")", ":", "last_seen_guid", "=", "None", "while", "True", ":", "u", "=", "urllib2", ".", "urlopen", "(", "'https://www.openstreetmap.org/ap...
532dffceae91e2bce89c530ceff627bc8210f8aa
test
ConditionController.passes_filter
Returns true if the condition passes the filter
registrasion/controllers/conditions.py
def passes_filter(self, user): ''' Returns true if the condition passes the filter ''' cls = type(self.condition) qs = cls.objects.filter(pk=self.condition.id) return self.condition in self.pre_filter(qs, user)
def passes_filter(self, user): ''' Returns true if the condition passes the filter ''' cls = type(self.condition) qs = cls.objects.filter(pk=self.condition.id) return self.condition in self.pre_filter(qs, user)
[ "Returns", "true", "if", "the", "condition", "passes", "the", "filter" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L75-L80
[ "def", "passes_filter", "(", "self", ",", "user", ")", ":", "cls", "=", "type", "(", "self", ".", "condition", ")", "qs", "=", "cls", ".", "objects", ".", "filter", "(", "pk", "=", "self", ".", "condition", ".", "id", ")", "return", "self", ".", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ConditionController.user_quantity_remaining
Returns the number of items covered by this flag condition the user can add to the current cart. This default implementation returns a big number if is_met() is true, otherwise 0. Either this method, or is_met() must be overridden in subclasses.
registrasion/controllers/conditions.py
def user_quantity_remaining(self, user, filtered=False): ''' Returns the number of items covered by this flag condition the user can add to the current cart. This default implementation returns a big number if is_met() is true, otherwise 0. Either this method, or is_met() must be overri...
def user_quantity_remaining(self, user, filtered=False): ''' Returns the number of items covered by this flag condition the user can add to the current cart. This default implementation returns a big number if is_met() is true, otherwise 0. Either this method, or is_met() must be overri...
[ "Returns", "the", "number", "of", "items", "covered", "by", "this", "flag", "condition", "the", "user", "can", "add", "to", "the", "current", "cart", ".", "This", "default", "implementation", "returns", "a", "big", "number", "if", "is_met", "()", "is", "tr...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L82-L90
[ "def", "user_quantity_remaining", "(", "self", ",", "user", ",", "filtered", "=", "False", ")", ":", "return", "_BIG_QUANTITY", "if", "self", ".", "is_met", "(", "user", ",", "filtered", ")", "else", "0" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
IsMetByFilter.is_met
Returns True if this flag condition is met, otherwise returns False. It determines if the condition is met by calling pre_filter with a queryset containing only self.condition.
registrasion/controllers/conditions.py
def is_met(self, user, filtered=False): ''' Returns True if this flag condition is met, otherwise returns False. It determines if the condition is met by calling pre_filter with a queryset containing only self.condition. ''' if filtered: return True # Why query again? ...
def is_met(self, user, filtered=False): ''' Returns True if this flag condition is met, otherwise returns False. It determines if the condition is met by calling pre_filter with a queryset containing only self.condition. ''' if filtered: return True # Why query again? ...
[ "Returns", "True", "if", "this", "flag", "condition", "is", "met", "otherwise", "returns", "False", ".", "It", "determines", "if", "the", "condition", "is", "met", "by", "calling", "pre_filter", "with", "a", "queryset", "containing", "only", "self", ".", "co...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L112-L120
[ "def", "is_met", "(", "self", ",", "user", ",", "filtered", "=", "False", ")", ":", "if", "filtered", ":", "return", "True", "# Why query again?", "return", "self", ".", "passes_filter", "(", "user", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
RemainderSetByFilter.user_quantity_remaining
returns 0 if the date range is violated, otherwise, it will return the quantity remaining under the stock limit. The filter for this condition must add an annotation called "remainder" in order for this to work.
registrasion/controllers/conditions.py
def user_quantity_remaining(self, user, filtered=True): ''' returns 0 if the date range is violated, otherwise, it will return the quantity remaining under the stock limit. The filter for this condition must add an annotation called "remainder" in order for this to work. ''' ...
def user_quantity_remaining(self, user, filtered=True): ''' returns 0 if the date range is violated, otherwise, it will return the quantity remaining under the stock limit. The filter for this condition must add an annotation called "remainder" in order for this to work. ''' ...
[ "returns", "0", "if", "the", "date", "range", "is", "violated", "otherwise", "it", "will", "return", "the", "quantity", "remaining", "under", "the", "stock", "limit", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L125-L144
[ "def", "user_quantity_remaining", "(", "self", ",", "user", ",", "filtered", "=", "True", ")", ":", "if", "filtered", ":", "if", "hasattr", "(", "self", ".", "condition", ",", "\"remainder\"", ")", ":", "return", "self", ".", "condition", ".", "remainder",...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CategoryConditionController.pre_filter
Returns all of the items from queryset where the user has a product from a category invoking that item's condition in one of their carts.
registrasion/controllers/conditions.py
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the user has a product from a category invoking that item's condition in one of their carts. ''' in_user_carts = Q( enabling_category__product__productitem__cart__user=user ) ...
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the user has a product from a category invoking that item's condition in one of their carts. ''' in_user_carts = Q( enabling_category__product__productitem__cart__user=user ) ...
[ "Returns", "all", "of", "the", "items", "from", "queryset", "where", "the", "user", "has", "a", "product", "from", "a", "category", "invoking", "that", "item", "s", "condition", "in", "one", "of", "their", "carts", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L150-L165
[ "def", "pre_filter", "(", "self", ",", "queryset", ",", "user", ")", ":", "in_user_carts", "=", "Q", "(", "enabling_category__product__productitem__cart__user", "=", "user", ")", "released", "=", "commerce", ".", "Cart", ".", "STATUS_RELEASED", "in_released_carts", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ProductConditionController.pre_filter
Returns all of the items from queryset where the user has a product invoking that item's condition in one of their carts.
registrasion/controllers/conditions.py
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the user has a product invoking that item's condition in one of their carts. ''' in_user_carts = Q(enabling_products__productitem__cart__user=user) released = commerce.Cart.STATUS_RELEASED pai...
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the user has a product invoking that item's condition in one of their carts. ''' in_user_carts = Q(enabling_products__productitem__cart__user=user) released = commerce.Cart.STATUS_RELEASED pai...
[ "Returns", "all", "of", "the", "items", "from", "queryset", "where", "the", "user", "has", "a", "product", "invoking", "that", "item", "s", "condition", "in", "one", "of", "their", "carts", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L173-L194
[ "def", "pre_filter", "(", "self", ",", "queryset", ",", "user", ")", ":", "in_user_carts", "=", "Q", "(", "enabling_products__productitem__cart__user", "=", "user", ")", "released", "=", "commerce", ".", "Cart", ".", "STATUS_RELEASED", "paid", "=", "commerce", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
TimeOrStockLimitConditionController.pre_filter
Returns all of the items from queryset where the date falls into any specified range, but not yet where the stock limit is not yet reached.
registrasion/controllers/conditions.py
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the date falls into any specified range, but not yet where the stock limit is not yet reached.''' now = timezone.now() # Keep items with no start time, or start time not yet met. quer...
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset where the date falls into any specified range, but not yet where the stock limit is not yet reached.''' now = timezone.now() # Keep items with no start time, or start time not yet met. quer...
[ "Returns", "all", "of", "the", "items", "from", "queryset", "where", "the", "date", "falls", "into", "any", "specified", "range", "but", "not", "yet", "where", "the", "stock", "limit", "is", "not", "yet", "reached", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L205-L227
[ "def", "pre_filter", "(", "self", ",", "queryset", ",", "user", ")", ":", "now", "=", "timezone", ".", "now", "(", ")", "# Keep items with no start time, or start time not yet met.", "queryset", "=", "queryset", ".", "filter", "(", "Q", "(", "start_time", "=", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
SpeakerConditionController.pre_filter
Returns all of the items from queryset which are enabled by a user being a presenter or copresenter of a non-cancelled proposal.
registrasion/controllers/conditions.py
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset which are enabled by a user being a presenter or copresenter of a non-cancelled proposal. ''' # Filter out cancelled proposals queryset = queryset.filter( proposal_kind__proposalbase__presentati...
def pre_filter(self, queryset, user): ''' Returns all of the items from queryset which are enabled by a user being a presenter or copresenter of a non-cancelled proposal. ''' # Filter out cancelled proposals queryset = queryset.filter( proposal_kind__proposalbase__presentati...
[ "Returns", "all", "of", "the", "items", "from", "queryset", "which", "are", "enabled", "by", "a", "user", "being", "a", "presenter", "or", "copresenter", "of", "a", "non", "-", "cancelled", "proposal", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L311-L332
[ "def", "pre_filter", "(", "self", ",", "queryset", ",", "user", ")", ":", "# Filter out cancelled proposals", "queryset", "=", "queryset", ".", "filter", "(", "proposal_kind__proposalbase__presentation__cancelled", "=", "False", ")", "u", "=", "user", "# User is a pre...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
GroupMemberConditionController.pre_filter
Returns all of the items from conditions which are enabled by a user being member of a Django Auth Group.
registrasion/controllers/conditions.py
def pre_filter(self, conditions, user): ''' Returns all of the items from conditions which are enabled by a user being member of a Django Auth Group. ''' return conditions.filter(group__in=user.groups.all())
def pre_filter(self, conditions, user): ''' Returns all of the items from conditions which are enabled by a user being member of a Django Auth Group. ''' return conditions.filter(group__in=user.groups.all())
[ "Returns", "all", "of", "the", "items", "from", "conditions", "which", "are", "enabled", "by", "a", "user", "being", "member", "of", "a", "Django", "Auth", "Group", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/conditions.py#L338-L342
[ "def", "pre_filter", "(", "self", ",", "conditions", ",", "user", ")", ":", "return", "conditions", ".", "filter", "(", "group__in", "=", "user", ".", "groups", ".", "all", "(", ")", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_modifies_cart
Decorator that makes the wrapped function raise ValidationError if we're doing something that could modify the cart. It also wraps the execution of this function in a database transaction, and marks the boundaries of a cart operations batch.
registrasion/controllers/cart.py
def _modifies_cart(func): ''' Decorator that makes the wrapped function raise ValidationError if we're doing something that could modify the cart. It also wraps the execution of this function in a database transaction, and marks the boundaries of a cart operations batch. ''' @functools.wraps(f...
def _modifies_cart(func): ''' Decorator that makes the wrapped function raise ValidationError if we're doing something that could modify the cart. It also wraps the execution of this function in a database transaction, and marks the boundaries of a cart operations batch. ''' @functools.wraps(f...
[ "Decorator", "that", "makes", "the", "wrapped", "function", "raise", "ValidationError", "if", "we", "re", "doing", "something", "that", "could", "modify", "the", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L25-L42
[ "def", "_modifies_cart", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner", "(", "self", ",", "*", "a", ",", "*", "*", "k", ")", ":", "self", ".", "_fail_if_cart_is_not_active", "(", ")", "with", "transaction", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.for_user
Returns the user's current cart, or creates a new cart if there isn't one ready yet.
registrasion/controllers/cart.py
def for_user(cls, user): ''' Returns the user's current cart, or creates a new cart if there isn't one ready yet. ''' try: existing = commerce.Cart.objects.get( user=user, status=commerce.Cart.STATUS_ACTIVE, ) except ObjectDoesNotE...
def for_user(cls, user): ''' Returns the user's current cart, or creates a new cart if there isn't one ready yet. ''' try: existing = commerce.Cart.objects.get( user=user, status=commerce.Cart.STATUS_ACTIVE, ) except ObjectDoesNotE...
[ "Returns", "the", "user", "s", "current", "cart", "or", "creates", "a", "new", "cart", "if", "there", "isn", "t", "one", "ready", "yet", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L52-L67
[ "def", "for_user", "(", "cls", ",", "user", ")", ":", "try", ":", "existing", "=", "commerce", ".", "Cart", ".", "objects", ".", "get", "(", "user", "=", "user", ",", "status", "=", "commerce", ".", "Cart", ".", "STATUS_ACTIVE", ",", ")", "except", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController._autoextend_reservation
Updates the cart's time last updated value, which is used to determine whether the cart has reserved the items and discounts it holds.
registrasion/controllers/cart.py
def _autoextend_reservation(self): ''' Updates the cart's time last updated value, which is used to determine whether the cart has reserved the items and discounts it holds. ''' time = timezone.now() # Calculate the residual of the _old_ reservation duration # if it's g...
def _autoextend_reservation(self): ''' Updates the cart's time last updated value, which is used to determine whether the cart has reserved the items and discounts it holds. ''' time = timezone.now() # Calculate the residual of the _old_ reservation duration # if it's g...
[ "Updates", "the", "cart", "s", "time", "last", "updated", "value", "which", "is", "used", "to", "determine", "whether", "the", "cart", "has", "reserved", "the", "items", "and", "discounts", "it", "holds", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L74-L101
[ "def", "_autoextend_reservation", "(", "self", ")", ":", "time", "=", "timezone", ".", "now", "(", ")", "# Calculate the residual of the _old_ reservation duration", "# if it's greater than what's in the cart now, keep it.", "time_elapsed_since_updated", "=", "(", "time", "-", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController._end_batch
Performs operations that occur occur at the end of a batch of product changes/voucher applications etc. You need to call this after you've finished modifying the user's cart. This is normally done by wrapping a block of code using ``operations_batch``.
registrasion/controllers/cart.py
def _end_batch(self): ''' Performs operations that occur occur at the end of a batch of product changes/voucher applications etc. You need to call this after you've finished modifying the user's cart. This is normally done by wrapping a block of code using ``operations_batch``. ...
def _end_batch(self): ''' Performs operations that occur occur at the end of a batch of product changes/voucher applications etc. You need to call this after you've finished modifying the user's cart. This is normally done by wrapping a block of code using ``operations_batch``. ...
[ "Performs", "operations", "that", "occur", "occur", "at", "the", "end", "of", "a", "batch", "of", "product", "changes", "/", "voucher", "applications", "etc", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L109-L125
[ "def", "_end_batch", "(", "self", ")", ":", "self", ".", "cart", ".", "refresh_from_db", "(", ")", "self", ".", "_recalculate_discounts", "(", ")", "self", ".", "_autoextend_reservation", "(", ")", "self", ".", "cart", ".", "revision", "+=", "1", "self", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.extend_reservation
Extends the reservation on this cart by the given timedelta. This can only be done if the current state of the cart is valid (i.e all items and discounts in the cart are still available.) Arguments: timedelta (timedelta): The amount of time to extend the cart by. The...
registrasion/controllers/cart.py
def extend_reservation(self, timedelta): ''' Extends the reservation on this cart by the given timedelta. This can only be done if the current state of the cart is valid (i.e all items and discounts in the cart are still available.) Arguments: timedelta (timedelta): The amou...
def extend_reservation(self, timedelta): ''' Extends the reservation on this cart by the given timedelta. This can only be done if the current state of the cart is valid (i.e all items and discounts in the cart are still available.) Arguments: timedelta (timedelta): The amou...
[ "Extends", "the", "reservation", "on", "this", "cart", "by", "the", "given", "timedelta", ".", "This", "can", "only", "be", "done", "if", "the", "current", "state", "of", "the", "cart", "is", "valid", "(", "i", ".", "e", "all", "items", "and", "discoun...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L127-L151
[ "def", "extend_reservation", "(", "self", ",", "timedelta", ")", ":", "self", ".", "validate_cart", "(", ")", "cart", "=", "self", ".", "cart", "cart", ".", "refresh_from_db", "(", ")", "elapsed", "=", "(", "timezone", ".", "now", "(", ")", "-", "cart"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.set_quantities
Sets the quantities on each of the products on each of the products specified. Raises an exception (ValidationError) if a limit is violated. `product_quantities` is an iterable of (product, quantity) pairs.
registrasion/controllers/cart.py
def set_quantities(self, product_quantities): ''' Sets the quantities on each of the products on each of the products specified. Raises an exception (ValidationError) if a limit is violated. `product_quantities` is an iterable of (product, quantity) pairs. ''' items_in_cart = co...
def set_quantities(self, product_quantities): ''' Sets the quantities on each of the products on each of the products specified. Raises an exception (ValidationError) if a limit is violated. `product_quantities` is an iterable of (product, quantity) pairs. ''' items_in_cart = co...
[ "Sets", "the", "quantities", "on", "each", "of", "the", "products", "on", "each", "of", "the", "products", "specified", ".", "Raises", "an", "exception", "(", "ValidationError", ")", "if", "a", "limit", "is", "violated", ".", "product_quantities", "is", "an"...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L154-L208
[ "def", "set_quantities", "(", "self", ",", "product_quantities", ")", ":", "items_in_cart", "=", "commerce", ".", "ProductItem", ".", "objects", ".", "filter", "(", "cart", "=", "self", ".", "cart", ")", "items_in_cart", "=", "items_in_cart", ".", "select_rela...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.apply_voucher
Applies the voucher with the given code to this cart.
registrasion/controllers/cart.py
def apply_voucher(self, voucher_code): ''' Applies the voucher with the given code to this cart. ''' # Try and find the voucher voucher = inventory.Voucher.objects.get(code=voucher_code.upper()) # Re-applying vouchers should be idempotent if voucher in self.cart.vouchers.all():...
def apply_voucher(self, voucher_code): ''' Applies the voucher with the given code to this cart. ''' # Try and find the voucher voucher = inventory.Voucher.objects.get(code=voucher_code.upper()) # Re-applying vouchers should be idempotent if voucher in self.cart.vouchers.all():...
[ "Applies", "the", "voucher", "with", "the", "given", "code", "to", "this", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L271-L284
[ "def", "apply_voucher", "(", "self", ",", "voucher_code", ")", ":", "# Try and find the voucher", "voucher", "=", "inventory", ".", "Voucher", ".", "objects", ".", "get", "(", "code", "=", "voucher_code", ".", "upper", "(", ")", ")", "# Re-applying vouchers shou...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.validate_cart
Determines whether the status of the current cart is valid; this is normally called before generating or paying an invoice
registrasion/controllers/cart.py
def validate_cart(self): ''' Determines whether the status of the current cart is valid; this is normally called before generating or paying an invoice ''' cart = self.cart user = self.cart.user errors = [] try: self._test_vouchers(self.cart.vouchers.all()) ...
def validate_cart(self): ''' Determines whether the status of the current cart is valid; this is normally called before generating or paying an invoice ''' cart = self.cart user = self.cart.user errors = [] try: self._test_vouchers(self.cart.vouchers.all()) ...
[ "Determines", "whether", "the", "status", "of", "the", "current", "cart", "is", "valid", ";", "this", "is", "normally", "called", "before", "generating", "or", "paying", "an", "invoice" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L352-L403
[ "def", "validate_cart", "(", "self", ")", ":", "cart", "=", "self", ".", "cart", "user", "=", "self", ".", "cart", ".", "user", "errors", "=", "[", "]", "try", ":", "self", ".", "_test_vouchers", "(", "self", ".", "cart", ".", "vouchers", ".", "all...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController.fix_simple_errors
This attempts to fix the easy errors raised by ValidationError. This includes removing items from the cart that are no longer available, recalculating all of the discounts, and removing voucher codes that are no longer available.
registrasion/controllers/cart.py
def fix_simple_errors(self): ''' This attempts to fix the easy errors raised by ValidationError. This includes removing items from the cart that are no longer available, recalculating all of the discounts, and removing voucher codes that are no longer available. ''' # Fix vouche...
def fix_simple_errors(self): ''' This attempts to fix the easy errors raised by ValidationError. This includes removing items from the cart that are no longer available, recalculating all of the discounts, and removing voucher codes that are no longer available. ''' # Fix vouche...
[ "This", "attempts", "to", "fix", "the", "easy", "errors", "raised", "by", "ValidationError", ".", "This", "includes", "removing", "items", "from", "the", "cart", "that", "are", "no", "longer", "available", "recalculating", "all", "of", "the", "discounts", "and...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L406-L435
[ "def", "fix_simple_errors", "(", "self", ")", ":", "# Fix vouchers first (this affects available discounts)", "to_remove", "=", "[", "]", "for", "voucher", "in", "self", ".", "cart", ".", "vouchers", ".", "all", "(", ")", ":", "try", ":", "self", ".", "_test_v...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController._recalculate_discounts
Calculates all of the discounts available for this product.
registrasion/controllers/cart.py
def _recalculate_discounts(self): ''' Calculates all of the discounts available for this product.''' # Delete the existing entries. commerce.DiscountItem.objects.filter(cart=self.cart).delete() # Order the products such that the most expensive ones are # processed first. ...
def _recalculate_discounts(self): ''' Calculates all of the discounts available for this product.''' # Delete the existing entries. commerce.DiscountItem.objects.filter(cart=self.cart).delete() # Order the products such that the most expensive ones are # processed first. ...
[ "Calculates", "all", "of", "the", "discounts", "available", "for", "this", "product", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L438-L460
[ "def", "_recalculate_discounts", "(", "self", ")", ":", "# Delete the existing entries.", "commerce", ".", "DiscountItem", ".", "objects", ".", "filter", "(", "cart", "=", "self", ".", "cart", ")", ".", "delete", "(", ")", "# Order the products such that the most ex...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CartController._add_discount
Applies the best discounts on the given product, from the given discounts.
registrasion/controllers/cart.py
def _add_discount(self, product, quantity, discounts): ''' Applies the best discounts on the given product, from the given discounts.''' def matches(discount): ''' Returns True if and only if the given discount apples to our product. ''' if isinstance(discoun...
def _add_discount(self, product, quantity, discounts): ''' Applies the best discounts on the given product, from the given discounts.''' def matches(discount): ''' Returns True if and only if the given discount apples to our product. ''' if isinstance(discoun...
[ "Applies", "the", "best", "discounts", "on", "the", "given", "product", "from", "the", "given", "discounts", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/cart.py#L462-L512
[ "def", "_add_discount", "(", "self", ",", "product", ",", "quantity", ",", "discounts", ")", ":", "def", "matches", "(", "discount", ")", ":", "''' Returns True if and only if the given discount apples to\n our product. '''", "if", "isinstance", "(", "discount"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
report_view
Decorator that converts a report view function into something that displays a Report. Arguments: title (str): The title of the report. form_type (Optional[forms.Form]): A form class that can make this report display things. If not supplied, no form will be di...
registrasion/reporting/reports.py
def report_view(title, form_type=None): ''' Decorator that converts a report view function into something that displays a Report. Arguments: title (str): The title of the report. form_type (Optional[forms.Form]): A form class that can make this report display things....
def report_view(title, form_type=None): ''' Decorator that converts a report view function into something that displays a Report. Arguments: title (str): The title of the report. form_type (Optional[forms.Form]): A form class that can make this report display things....
[ "Decorator", "that", "converts", "a", "report", "view", "function", "into", "something", "that", "displays", "a", "Report", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/reports.py#L186-L210
[ "def", "report_view", "(", "title", ",", "form_type", "=", "None", ")", ":", "# Create & return view", "def", "_report", "(", "view", ")", ":", "report_view", "=", "ReportView", "(", "view", ",", "title", ",", "form_type", ")", "report_view", "=", "user_pass...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ListReport.rows
Returns the data rows for the table.
registrasion/reporting/reports.py
def rows(self, content_type): ''' Returns the data rows for the table. ''' for row in self._data: yield [ self.cell_text(content_type, i, cell) for i, cell in enumerate(row) ]
def rows(self, content_type): ''' Returns the data rows for the table. ''' for row in self._data: yield [ self.cell_text(content_type, i, cell) for i, cell in enumerate(row) ]
[ "Returns", "the", "data", "rows", "for", "the", "table", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/reports.py#L112-L119
[ "def", "rows", "(", "self", ",", "content_type", ")", ":", "for", "row", "in", "self", ".", "_data", ":", "yield", "[", "self", ".", "cell_text", "(", "content_type", ",", "i", ",", "cell", ")", "for", "i", ",", "cell", "in", "enumerate", "(", "row...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ReportView.get_form
Creates an instance of self.form_type using request.GET
registrasion/reporting/reports.py
def get_form(self, request): ''' Creates an instance of self.form_type using request.GET ''' # Create a form instance if self.form_type is not None: form = self.form_type(request.GET) # Pre-validate it form.is_valid() else: form = None ...
def get_form(self, request): ''' Creates an instance of self.form_type using request.GET ''' # Create a form instance if self.form_type is not None: form = self.form_type(request.GET) # Pre-validate it form.is_valid() else: form = None ...
[ "Creates", "an", "instance", "of", "self", ".", "form_type", "using", "request", ".", "GET" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/reports.py#L238-L251
[ "def", "get_form", "(", "self", ",", "request", ")", ":", "# Create a form instance", "if", "self", ".", "form_type", "is", "not", "None", ":", "form", "=", "self", ".", "form_type", "(", "request", ".", "GET", ")", "# Pre-validate it", "form", ".", "is_va...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ReportView.wrap_reports
Wraps the reports in a _ReportTemplateWrapper for the given content_type -- this allows data to be returned as HTML links, for instance.
registrasion/reporting/reports.py
def wrap_reports(cls, reports, content_type): ''' Wraps the reports in a _ReportTemplateWrapper for the given content_type -- this allows data to be returned as HTML links, for instance. ''' reports = [ _ReportTemplateWrapper(content_type, report) for report in r...
def wrap_reports(cls, reports, content_type): ''' Wraps the reports in a _ReportTemplateWrapper for the given content_type -- this allows data to be returned as HTML links, for instance. ''' reports = [ _ReportTemplateWrapper(content_type, report) for report in r...
[ "Wraps", "the", "reports", "in", "a", "_ReportTemplateWrapper", "for", "the", "given", "content_type", "--", "this", "allows", "data", "to", "be", "returned", "as", "HTML", "links", "for", "instance", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/reports.py#L254-L264
[ "def", "wrap_reports", "(", "cls", ",", "reports", ",", "content_type", ")", ":", "reports", "=", "[", "_ReportTemplateWrapper", "(", "content_type", ",", "report", ")", "for", "report", "in", "reports", "]", "return", "reports" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ReportView.render
Renders the reports based on data.content_type's value. Arguments: data (ReportViewRequestData): The report data. data.content_type is used to determine how the reports are rendered. Returns: HTTPResponse: The rendered version of the report.
registrasion/reporting/reports.py
def render(self, data): ''' Renders the reports based on data.content_type's value. Arguments: data (ReportViewRequestData): The report data. data.content_type is used to determine how the reports are rendered. Returns: HTTPResponse: The rendered version...
def render(self, data): ''' Renders the reports based on data.content_type's value. Arguments: data (ReportViewRequestData): The report data. data.content_type is used to determine how the reports are rendered. Returns: HTTPResponse: The rendered version...
[ "Renders", "the", "reports", "based", "on", "data", ".", "content_type", "s", "value", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/reports.py#L266-L283
[ "def", "render", "(", "self", ",", "data", ")", ":", "renderers", "=", "{", "\"text/csv\"", ":", "self", ".", "_render_as_csv", ",", "\"text/html\"", ":", "self", ".", "_render_as_html", ",", "None", ":", "self", ".", "_render_as_html", ",", "}", "render",...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
reports_list
Lists all of the reports currently available.
registrasion/reporting/views.py
def reports_list(request): ''' Lists all of the reports currently available. ''' reports = [] for report in get_all_reports(): reports.append({ "name": report.__name__, "url": reverse(report), "description": report.__doc__, }) reports.sort(key=lambd...
def reports_list(request): ''' Lists all of the reports currently available. ''' reports = [] for report in get_all_reports(): reports.append({ "name": report.__name__, "url": reverse(report), "description": report.__doc__, }) reports.sort(key=lambd...
[ "Lists", "all", "of", "the", "reports", "currently", "available", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L42-L60
[ "def", "reports_list", "(", "request", ")", ":", "reports", "=", "[", "]", "for", "report", "in", "get_all_reports", "(", ")", ":", "reports", ".", "append", "(", "{", "\"name\"", ":", "report", ".", "__name__", ",", "\"url\"", ":", "reverse", "(", "re...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
items_sold
Summarises the items sold and discounts granted for a given set of products, or products from categories.
registrasion/reporting/views.py
def items_sold(): ''' Summarises the items sold and discounts granted for a given set of products, or products from categories. ''' data = None headings = None line_items = commerce.LineItem.objects.filter( invoice__status=commerce.Invoice.STATUS_PAID, ).select_related("invoice") ...
def items_sold(): ''' Summarises the items sold and discounts granted for a given set of products, or products from categories. ''' data = None headings = None line_items = commerce.LineItem.objects.filter( invoice__status=commerce.Invoice.STATUS_PAID, ).select_related("invoice") ...
[ "Summarises", "the", "items", "sold", "and", "discounts", "granted", "for", "a", "given", "set", "of", "products", "or", "products", "from", "categories", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L78-L114
[ "def", "items_sold", "(", ")", ":", "data", "=", "None", "headings", "=", "None", "line_items", "=", "commerce", ".", "LineItem", ".", "objects", ".", "filter", "(", "invoice__status", "=", "commerce", ".", "Invoice", ".", "STATUS_PAID", ",", ")", ".", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
sales_payment_summary
Summarises paid items and payments.
registrasion/reporting/views.py
def sales_payment_summary(): ''' Summarises paid items and payments. ''' def value_or_zero(aggregate, key): return aggregate[key] or 0 def sum_amount(payment_set): a = payment_set.values("amount").aggregate(total=Sum("amount")) return value_or_zero(a, "total") headings = ["Cat...
def sales_payment_summary(): ''' Summarises paid items and payments. ''' def value_or_zero(aggregate, key): return aggregate[key] or 0 def sum_amount(payment_set): a = payment_set.values("amount").aggregate(total=Sum("amount")) return value_or_zero(a, "total") headings = ["Cat...
[ "Summarises", "paid", "items", "and", "payments", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L117-L167
[ "def", "sales_payment_summary", "(", ")", ":", "def", "value_or_zero", "(", "aggregate", ",", "key", ")", ":", "return", "aggregate", "[", "key", "]", "or", "0", "def", "sum_amount", "(", "payment_set", ")", ":", "a", "=", "payment_set", ".", "values", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
payments
Shows the history of payments into the system
registrasion/reporting/views.py
def payments(): ''' Shows the history of payments into the system ''' payments = commerce.PaymentBase.objects.all() return QuerysetReport( "Payments", ["invoice__id", "id", "reference", "amount"], payments, link_view=views.invoice, )
def payments(): ''' Shows the history of payments into the system ''' payments = commerce.PaymentBase.objects.all() return QuerysetReport( "Payments", ["invoice__id", "id", "reference", "amount"], payments, link_view=views.invoice, )
[ "Shows", "the", "history", "of", "payments", "into", "the", "system" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L170-L179
[ "def", "payments", "(", ")", ":", "payments", "=", "commerce", ".", "PaymentBase", ".", "objects", ".", "all", "(", ")", "return", "QuerysetReport", "(", "\"Payments\"", ",", "[", "\"invoice__id\"", ",", "\"id\"", ",", "\"reference\"", ",", "\"amount\"", "]"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
credit_note_refunds
Shows all of the credit notes that have been generated.
registrasion/reporting/views.py
def credit_note_refunds(): ''' Shows all of the credit notes that have been generated. ''' notes_refunded = commerce.CreditNote.refunded() return QuerysetReport( "Credit note refunds", ["id", "creditnoterefund__reference", "amount"], notes_refunded, link_view=views.credit_not...
def credit_note_refunds(): ''' Shows all of the credit notes that have been generated. ''' notes_refunded = commerce.CreditNote.refunded() return QuerysetReport( "Credit note refunds", ["id", "creditnoterefund__reference", "amount"], notes_refunded, link_view=views.credit_not...
[ "Shows", "all", "of", "the", "credit", "notes", "that", "have", "been", "generated", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L182-L190
[ "def", "credit_note_refunds", "(", ")", ":", "notes_refunded", "=", "commerce", ".", "CreditNote", ".", "refunded", "(", ")", "return", "QuerysetReport", "(", "\"Credit note refunds\"", ",", "[", "\"id\"", ",", "\"creditnoterefund__reference\"", ",", "\"amount\"", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
product_status
Summarises the inventory status of the given items, grouping by invoice status.
registrasion/reporting/views.py
def product_status(request, form): ''' Summarises the inventory status of the given items, grouping by invoice status. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] items = commerce.ProductItem.objects.filter( Q(product__in=products) | Q(product__ca...
def product_status(request, form): ''' Summarises the inventory status of the given items, grouping by invoice status. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] items = commerce.ProductItem.objects.filter( Q(product__in=products) | Q(product__ca...
[ "Summarises", "the", "inventory", "status", "of", "the", "given", "items", "grouping", "by", "invoice", "status", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L244-L277
[ "def", "product_status", "(", "request", ",", "form", ")", ":", "products", "=", "form", ".", "cleaned_data", "[", "\"product\"", "]", "categories", "=", "form", ".", "cleaned_data", "[", "\"category\"", "]", "items", "=", "commerce", ".", "ProductItem", "."...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
discount_status
Summarises the usage of a given discount.
registrasion/reporting/views.py
def discount_status(request, form): ''' Summarises the usage of a given discount. ''' discounts = form.cleaned_data["discount"] items = commerce.DiscountItem.objects.filter( Q(discount__in=discounts), ).select_related("cart", "product", "product__category") items = group_by_cart_status( ...
def discount_status(request, form): ''' Summarises the usage of a given discount. ''' discounts = form.cleaned_data["discount"] items = commerce.DiscountItem.objects.filter( Q(discount__in=discounts), ).select_related("cart", "product", "product__category") items = group_by_cart_status( ...
[ "Summarises", "the", "usage", "of", "a", "given", "discount", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L281-L310
[ "def", "discount_status", "(", "request", ",", "form", ")", ":", "discounts", "=", "form", ".", "cleaned_data", "[", "\"discount\"", "]", "items", "=", "commerce", ".", "DiscountItem", ".", "objects", ".", "filter", "(", "Q", "(", "discount__in", "=", "dis...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
product_line_items
Shows each product line item from invoices, including their date and purchashing customer.
registrasion/reporting/views.py
def product_line_items(request, form): ''' Shows each product line item from invoices, including their date and purchashing customer. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] invoices = commerce.Invoice.objects.filter( ( Q(lineitem_...
def product_line_items(request, form): ''' Shows each product line item from invoices, including their date and purchashing customer. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] invoices = commerce.Invoice.objects.filter( ( Q(lineitem_...
[ "Shows", "each", "product", "line", "item", "from", "invoices", "including", "their", "date", "and", "purchashing", "customer", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L314-L359
[ "def", "product_line_items", "(", "request", ",", "form", ")", ":", "products", "=", "form", ".", "cleaned_data", "[", "\"product\"", "]", "categories", "=", "form", ".", "cleaned_data", "[", "\"category\"", "]", "invoices", "=", "commerce", ".", "Invoice", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
paid_invoices_by_date
Shows the number of paid invoices containing given products or categories per day.
registrasion/reporting/views.py
def paid_invoices_by_date(request, form): ''' Shows the number of paid invoices containing given products or categories per day. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] invoices = commerce.Invoice.objects.filter( ( Q(lineitem__prod...
def paid_invoices_by_date(request, form): ''' Shows the number of paid invoices containing given products or categories per day. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] invoices = commerce.Invoice.objects.filter( ( Q(lineitem__prod...
[ "Shows", "the", "number", "of", "paid", "invoices", "containing", "given", "products", "or", "categories", "per", "day", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L363-L410
[ "def", "paid_invoices_by_date", "(", "request", ",", "form", ")", ":", "products", "=", "form", ".", "cleaned_data", "[", "\"product\"", "]", "categories", "=", "form", ".", "cleaned_data", "[", "\"category\"", "]", "invoices", "=", "commerce", ".", "Invoice",...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
credit_notes
Shows all of the credit notes in the system.
registrasion/reporting/views.py
def credit_notes(request, form): ''' Shows all of the credit notes in the system. ''' notes = commerce.CreditNote.objects.all().select_related( "creditnoterefund", "creditnoteapplication", "invoice", "invoice__user__attendee__attendeeprofilebase", ) return QuerysetRepor...
def credit_notes(request, form): ''' Shows all of the credit notes in the system. ''' notes = commerce.CreditNote.objects.all().select_related( "creditnoterefund", "creditnoteapplication", "invoice", "invoice__user__attendee__attendeeprofilebase", ) return QuerysetRepor...
[ "Shows", "all", "of", "the", "credit", "notes", "in", "the", "system", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L414-L432
[ "def", "credit_notes", "(", "request", ",", "form", ")", ":", "notes", "=", "commerce", ".", "CreditNote", ".", "objects", ".", "all", "(", ")", ".", "select_related", "(", "\"creditnoterefund\"", ",", "\"creditnoteapplication\"", ",", "\"invoice\"", ",", "\"i...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
invoices
Shows all of the invoices in the system.
registrasion/reporting/views.py
def invoices(request, form): ''' Shows all of the invoices in the system. ''' invoices = commerce.Invoice.objects.all().order_by("status", "id") return QuerysetReport( "Invoices", ["id", "recipient", "value", "get_status_display"], invoices, headings=["id", "Recipient", "Va...
def invoices(request, form): ''' Shows all of the invoices in the system. ''' invoices = commerce.Invoice.objects.all().order_by("status", "id") return QuerysetReport( "Invoices", ["id", "recipient", "value", "get_status_display"], invoices, headings=["id", "Recipient", "Va...
[ "Shows", "all", "of", "the", "invoices", "in", "the", "system", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L436-L447
[ "def", "invoices", "(", "request", ",", "form", ")", ":", "invoices", "=", "commerce", ".", "Invoice", ".", "objects", ".", "all", "(", ")", ".", "order_by", "(", "\"status\"", ",", "\"id\"", ")", "return", "QuerysetReport", "(", "\"Invoices\"", ",", "["...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
attendee
Returns a list of all manifested attendees if no attendee is specified, else displays the attendee manifest.
registrasion/reporting/views.py
def attendee(request, form, user_id=None): ''' Returns a list of all manifested attendees if no attendee is specified, else displays the attendee manifest. ''' if user_id is None and form.cleaned_data["user"] is not None: user_id = form.cleaned_data["user"] if user_id is None: return a...
def attendee(request, form, user_id=None): ''' Returns a list of all manifested attendees if no attendee is specified, else displays the attendee manifest. ''' if user_id is None and form.cleaned_data["user"] is not None: user_id = form.cleaned_data["user"] if user_id is None: return a...
[ "Returns", "a", "list", "of", "all", "manifested", "attendees", "if", "no", "attendee", "is", "specified", "else", "displays", "the", "attendee", "manifest", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L457-L566
[ "def", "attendee", "(", "request", ",", "form", ",", "user_id", "=", "None", ")", ":", "if", "user_id", "is", "None", "and", "form", ".", "cleaned_data", "[", "\"user\"", "]", "is", "not", "None", ":", "user_id", "=", "form", ".", "cleaned_data", "[", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
attendee_list
Returns a list of all attendees.
registrasion/reporting/views.py
def attendee_list(request): ''' Returns a list of all attendees. ''' attendees = people.Attendee.objects.select_related( "attendeeprofilebase", "user", ) profiles = AttendeeProfile.objects.filter( attendee__in=attendees ).select_related( "attendee", "attendee__user"...
def attendee_list(request): ''' Returns a list of all attendees. ''' attendees = people.Attendee.objects.select_related( "attendeeprofilebase", "user", ) profiles = AttendeeProfile.objects.filter( attendee__in=attendees ).select_related( "attendee", "attendee__user"...
[ "Returns", "a", "list", "of", "all", "attendees", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L569-L608
[ "def", "attendee_list", "(", "request", ")", ":", "attendees", "=", "people", ".", "Attendee", ".", "objects", ".", "select_related", "(", "\"attendeeprofilebase\"", ",", "\"user\"", ",", ")", "profiles", "=", "AttendeeProfile", ".", "objects", ".", "filter", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
attendee_data
Lists attendees for a given product/category selection along with profile data.
registrasion/reporting/views.py
def attendee_data(request, form, user_id=None): ''' Lists attendees for a given product/category selection along with profile data.''' status_display = { commerce.Cart.STATUS_ACTIVE: "Unpaid", commerce.Cart.STATUS_PAID: "Paid", commerce.Cart.STATUS_RELEASED: "Refunded", } o...
def attendee_data(request, form, user_id=None): ''' Lists attendees for a given product/category selection along with profile data.''' status_display = { commerce.Cart.STATUS_ACTIVE: "Unpaid", commerce.Cart.STATUS_PAID: "Paid", commerce.Cart.STATUS_RELEASED: "Refunded", } o...
[ "Lists", "attendees", "for", "a", "given", "product", "/", "category", "selection", "along", "with", "profile", "data", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L620-L784
[ "def", "attendee_data", "(", "request", ",", "form", ",", "user_id", "=", "None", ")", ":", "status_display", "=", "{", "commerce", ".", "Cart", ".", "STATUS_ACTIVE", ":", "\"Unpaid\"", ",", "commerce", ".", "Cart", ".", "STATUS_PAID", ":", "\"Paid\"", ","...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
speaker_registrations
Shows registration status for speakers with a given proposal kind.
registrasion/reporting/views.py
def speaker_registrations(request, form): ''' Shows registration status for speakers with a given proposal kind. ''' kinds = form.cleaned_data["kind"] presentations = schedule_models.Presentation.objects.filter( proposal_base__kind__in=kinds, ).exclude( cancelled=True, ) users...
def speaker_registrations(request, form): ''' Shows registration status for speakers with a given proposal kind. ''' kinds = form.cleaned_data["kind"] presentations = schedule_models.Presentation.objects.filter( proposal_base__kind__in=kinds, ).exclude( cancelled=True, ) users...
[ "Shows", "registration", "status", "for", "speakers", "with", "a", "given", "proposal", "kind", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L791-L824
[ "def", "speaker_registrations", "(", "request", ",", "form", ")", ":", "kinds", "=", "form", ".", "cleaned_data", "[", "\"kind\"", "]", "presentations", "=", "schedule_models", ".", "Presentation", ".", "objects", ".", "filter", "(", "proposal_base__kind__in", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
manifest
Produces the registration manifest for people with the given product type.
registrasion/reporting/views.py
def manifest(request, form): ''' Produces the registration manifest for people with the given product type. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] line_items = ( Q(lineitem__product__in=products) | Q(lineitem__product__categor...
def manifest(request, form): ''' Produces the registration manifest for people with the given product type. ''' products = form.cleaned_data["product"] categories = form.cleaned_data["category"] line_items = ( Q(lineitem__product__in=products) | Q(lineitem__product__categor...
[ "Produces", "the", "registration", "manifest", "for", "people", "with", "the", "given", "product", "type", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/reporting/views.py#L831-L911
[ "def", "manifest", "(", "request", ",", "form", ")", ":", "products", "=", "form", ".", "cleaned_data", "[", "\"product\"", "]", "categories", "=", "form", ".", "cleaned_data", "[", "\"category\"", "]", "line_items", "=", "(", "Q", "(", "lineitem__product__i...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
missing_categories
Adds the categories that the user does not currently have.
registrasion/templatetags/registrasion_tags.py
def missing_categories(context): ''' Adds the categories that the user does not currently have. ''' user = user_for_context(context) categories_available = set(CategoryController.available_categories(user)) items = ItemController(user).items_pending_or_purchased() categories_held = set() for p...
def missing_categories(context): ''' Adds the categories that the user does not currently have. ''' user = user_for_context(context) categories_available = set(CategoryController.available_categories(user)) items = ItemController(user).items_pending_or_purchased() categories_held = set() for p...
[ "Adds", "the", "categories", "that", "the", "user", "does", "not", "currently", "have", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L35-L46
[ "def", "missing_categories", "(", "context", ")", ":", "user", "=", "user_for_context", "(", "context", ")", "categories_available", "=", "set", "(", "CategoryController", ".", "available_categories", "(", "user", ")", ")", "items", "=", "ItemController", "(", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
available_credit
Calculates the sum of unclaimed credit from this user's credit notes. Returns: Decimal: the sum of the values of unclaimed credit notes for the current user.
registrasion/templatetags/registrasion_tags.py
def available_credit(context): ''' Calculates the sum of unclaimed credit from this user's credit notes. Returns: Decimal: the sum of the values of unclaimed credit notes for the current user. ''' notes = commerce.CreditNote.unclaimed().filter( invoice__user=user_for_conte...
def available_credit(context): ''' Calculates the sum of unclaimed credit from this user's credit notes. Returns: Decimal: the sum of the values of unclaimed credit notes for the current user. ''' notes = commerce.CreditNote.unclaimed().filter( invoice__user=user_for_conte...
[ "Calculates", "the", "sum", "of", "unclaimed", "credit", "from", "this", "user", "s", "credit", "notes", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L50-L63
[ "def", "available_credit", "(", "context", ")", ":", "notes", "=", "commerce", ".", "CreditNote", ".", "unclaimed", "(", ")", ".", "filter", "(", "invoice__user", "=", "user_for_context", "(", "context", ")", ",", ")", "ret", "=", "notes", ".", "values", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
total_items_purchased
Returns the number of items purchased for this user (sum of quantities). The user will be either `context.user`, and `context.request.user` if the former is not defined.
registrasion/templatetags/registrasion_tags.py
def total_items_purchased(context, category=None): ''' Returns the number of items purchased for this user (sum of quantities). The user will be either `context.user`, and `context.request.user` if the former is not defined. ''' return sum(i.quantity for i in items_purchased(context, category))
def total_items_purchased(context, category=None): ''' Returns the number of items purchased for this user (sum of quantities). The user will be either `context.user`, and `context.request.user` if the former is not defined. ''' return sum(i.quantity for i in items_purchased(context, category))
[ "Returns", "the", "number", "of", "items", "purchased", "for", "this", "user", "(", "sum", "of", "quantities", ")", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L100-L107
[ "def", "total_items_purchased", "(", "context", ",", "category", "=", "None", ")", ":", "return", "sum", "(", "i", ".", "quantity", "for", "i", "in", "items_purchased", "(", "context", ",", "category", ")", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
sold_out_and_unregistered
If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a pertinent question for people who already ha...
registrasion/templatetags/registrasion_tags.py
def sold_out_and_unregistered(context): ''' If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a ...
def sold_out_and_unregistered(context): ''' If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a ...
[ "If", "the", "current", "user", "is", "unregistered", "returns", "True", "if", "there", "are", "no", "products", "in", "the", "TICKET_PRODUCT_CATEGORY", "that", "are", "available", "to", "that", "user", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L124-L149
[ "def", "sold_out_and_unregistered", "(", "context", ")", ":", "user", "=", "user_for_context", "(", "context", ")", "if", "hasattr", "(", "user", ",", "\"attendee\"", ")", "and", "user", ".", "attendee", ".", "completed_registration", ":", "# This user has complet...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
include_if_exists
Usage: {% include_if_exists "head.html" %} This will fail silently if the template doesn't exist. If it does, it will be rendered with the current context. From: https://djangosnippets.org/snippets/2058/
registrasion/templatetags/registrasion_tags.py
def include_if_exists(parser, token): """Usage: {% include_if_exists "head.html" %} This will fail silently if the template doesn't exist. If it does, it will be rendered with the current context. From: https://djangosnippets.org/snippets/2058/ """ try: tag_name, template_name = token....
def include_if_exists(parser, token): """Usage: {% include_if_exists "head.html" %} This will fail silently if the template doesn't exist. If it does, it will be rendered with the current context. From: https://djangosnippets.org/snippets/2058/ """ try: tag_name, template_name = token....
[ "Usage", ":", "{", "%", "include_if_exists", "head", ".", "html", "%", "}" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L181-L195
[ "def", "include_if_exists", "(", "parser", ",", "token", ")", ":", "try", ":", "tag_name", ",", "template_name", "=", "token", ".", "split_contents", "(", ")", "except", "ValueError", ":", "raise", "template", ".", "TemplateSyntaxError", ",", "\"%r tag requires ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
guided_registration
Goes through the registration process in order, making sure user sees all valid categories. The user must be logged in to see this view. Parameter: page_number: 1) Profile form (and e-mail address?) 2) Ticket type 3) Remaining products 4) Mark regist...
registrasion/views.py
def guided_registration(request, page_number=None): ''' Goes through the registration process in order, making sure user sees all valid categories. The user must be logged in to see this view. Parameter: page_number: 1) Profile form (and e-mail address?) 2) Ticket type ...
def guided_registration(request, page_number=None): ''' Goes through the registration process in order, making sure user sees all valid categories. The user must be logged in to see this view. Parameter: page_number: 1) Profile form (and e-mail address?) 2) Ticket type ...
[ "Goes", "through", "the", "registration", "process", "in", "order", "making", "sure", "user", "sees", "all", "valid", "categories", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L68-L203
[ "def", "guided_registration", "(", "request", ",", "page_number", "=", "None", ")", ":", "PAGE_PROFILE", "=", "1", "PAGE_TICKET", "=", "2", "PAGE_PRODUCTS", "=", "3", "PAGE_PRODUCTS_MAX", "=", "4", "TOTAL_PAGES", "=", "4", "ticket_category", "=", "inventory", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
edit_profile
View for editing an attendee's profile The user must be logged in to edit their profile. Returns: redirect or render: In the case of a ``POST`` request, it'll redirect to ``dashboard``, or otherwise, it will render ``registrasion/profile_form.html`` with data:: ...
registrasion/views.py
def edit_profile(request): ''' View for editing an attendee's profile The user must be logged in to edit their profile. Returns: redirect or render: In the case of a ``POST`` request, it'll redirect to ``dashboard``, or otherwise, it will render ``registrasion/profile_form....
def edit_profile(request): ''' View for editing an attendee's profile The user must be logged in to edit their profile. Returns: redirect or render: In the case of a ``POST`` request, it'll redirect to ``dashboard``, or otherwise, it will render ``registrasion/profile_form....
[ "View", "for", "editing", "an", "attendee", "s", "profile" ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L327-L356
[ "def", "edit_profile", "(", "request", ")", ":", "form", ",", "handled", "=", "_handle_profile", "(", "request", ",", "\"profile\"", ")", "if", "handled", "and", "not", "form", ".", "errors", ":", "messages", ".", "success", "(", "request", ",", "\"Your at...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_handle_profile
Returns a profile form instance, and a boolean which is true if the form was handled.
registrasion/views.py
def _handle_profile(request, prefix): ''' Returns a profile form instance, and a boolean which is true if the form was handled. ''' attendee = people.Attendee.get_instance(request.user) try: profile = attendee.attendeeprofilebase profile = people.AttendeeProfileBase.objects.get_subclass...
def _handle_profile(request, prefix): ''' Returns a profile form instance, and a boolean which is true if the form was handled. ''' attendee = people.Attendee.get_instance(request.user) try: profile = attendee.attendeeprofilebase profile = people.AttendeeProfileBase.objects.get_subclass...
[ "Returns", "a", "profile", "form", "instance", "and", "a", "boolean", "which", "is", "true", "if", "the", "form", "was", "handled", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L369-L408
[ "def", "_handle_profile", "(", "request", ",", "prefix", ")", ":", "attendee", "=", "people", ".", "Attendee", ".", "get_instance", "(", "request", ".", "user", ")", "try", ":", "profile", "=", "attendee", ".", "attendeeprofilebase", "profile", "=", "people"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
product_category
Form for selecting products from an individual product category. Arguments: category_id (castable to int): The id of the category to display. Returns: redirect or render: If the form has been sucessfully submitted, redirect to ``dashboard``. Otherwise, render ...
registrasion/views.py
def product_category(request, category_id): ''' Form for selecting products from an individual product category. Arguments: category_id (castable to int): The id of the category to display. Returns: redirect or render: If the form has been sucessfully submitted, redirect to ...
def product_category(request, category_id): ''' Form for selecting products from an individual product category. Arguments: category_id (castable to int): The id of the category to display. Returns: redirect or render: If the form has been sucessfully submitted, redirect to ...
[ "Form", "for", "selecting", "products", "from", "an", "individual", "product", "category", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L412-L484
[ "def", "product_category", "(", "request", ",", "category_id", ")", ":", "PRODUCTS_FORM_PREFIX", "=", "\"products\"", "VOUCHERS_FORM_PREFIX", "=", "\"vouchers\"", "# Handle the voucher form *before* listing products.", "# Products can change as vouchers are entered.", "v", "=", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
voucher_code
A view *just* for entering a voucher form.
registrasion/views.py
def voucher_code(request): ''' A view *just* for entering a voucher form. ''' VOUCHERS_FORM_PREFIX = "vouchers" # Handle the voucher form *before* listing products. # Products can change as vouchers are entered. v = _handle_voucher(request, VOUCHERS_FORM_PREFIX) voucher_form, voucher_handled =...
def voucher_code(request): ''' A view *just* for entering a voucher form. ''' VOUCHERS_FORM_PREFIX = "vouchers" # Handle the voucher form *before* listing products. # Products can change as vouchers are entered. v = _handle_voucher(request, VOUCHERS_FORM_PREFIX) voucher_form, voucher_handled =...
[ "A", "view", "*", "just", "*", "for", "entering", "a", "voucher", "form", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L487-L505
[ "def", "voucher_code", "(", "request", ")", ":", "VOUCHERS_FORM_PREFIX", "=", "\"vouchers\"", "# Handle the voucher form *before* listing products.", "# Products can change as vouchers are entered.", "v", "=", "_handle_voucher", "(", "request", ",", "VOUCHERS_FORM_PREFIX", ")", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_handle_products
Handles a products list form in the given request. Returns the form instance, the discounts applicable to this form, and whether the contents were handled.
registrasion/views.py
def _handle_products(request, category, products, prefix): ''' Handles a products list form in the given request. Returns the form instance, the discounts applicable to this form, and whether the contents were handled. ''' current_cart = CartController.for_user(request.user) ProductsForm = forms.P...
def _handle_products(request, category, products, prefix): ''' Handles a products list form in the given request. Returns the form instance, the discounts applicable to this form, and whether the contents were handled. ''' current_cart = CartController.for_user(request.user) ProductsForm = forms.P...
[ "Handles", "a", "products", "list", "form", "in", "the", "given", "request", ".", "Returns", "the", "form", "instance", "the", "discounts", "applicable", "to", "this", "form", "and", "whether", "the", "contents", "were", "handled", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L509-L569
[ "def", "_handle_products", "(", "request", ",", "category", ",", "products", ",", "prefix", ")", ":", "current_cart", "=", "CartController", ".", "for_user", "(", "request", ".", "user", ")", "ProductsForm", "=", "forms", ".", "ProductsForm", "(", "category", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
_handle_voucher
Handles a voucher form in the given request. Returns the voucher form instance, and whether the voucher code was handled.
registrasion/views.py
def _handle_voucher(request, prefix): ''' Handles a voucher form in the given request. Returns the voucher form instance, and whether the voucher code was handled. ''' voucher_form = forms.VoucherForm(request.POST or None, prefix=prefix) current_cart = CartController.for_user(request.user) if (vou...
def _handle_voucher(request, prefix): ''' Handles a voucher form in the given request. Returns the voucher form instance, and whether the voucher code was handled. ''' voucher_form = forms.VoucherForm(request.POST or None, prefix=prefix) current_cart = CartController.for_user(request.user) if (vou...
[ "Handles", "a", "voucher", "form", "in", "the", "given", "request", ".", "Returns", "the", "voucher", "form", "instance", "and", "whether", "the", "voucher", "code", "was", "handled", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L599-L625
[ "def", "_handle_voucher", "(", "request", ",", "prefix", ")", ":", "voucher_form", "=", "forms", ".", "VoucherForm", "(", "request", ".", "POST", "or", "None", ",", "prefix", "=", "prefix", ")", "current_cart", "=", "CartController", ".", "for_user", "(", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
checkout
Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailable products. Arguments: user_...
registrasion/views.py
def checkout(request, user_id=None): ''' Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailabl...
def checkout(request, user_id=None): ''' Runs the checkout process for the current cart. If the query string contains ``fix_errors=true``, Registrasion will attempt to fix errors preventing the system from checking out, including by cancelling expired discounts and vouchers, and removing any unavailabl...
[ "Runs", "the", "checkout", "process", "for", "the", "current", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L629-L672
[ "def", "checkout", "(", "request", ",", "user_id", "=", "None", ")", ":", "if", "user_id", "is", "not", "None", ":", "if", "request", ".", "user", ".", "is_staff", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "id", "=", "int", "(", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
invoice_access
Redirects to an invoice for the attendee that matches the given access code, if any. If the attendee has multiple invoices, we use the following tie-break: - If there's an unpaid invoice, show that, otherwise - If there's a paid invoice, show the most recent one, otherwise - Show the most recent i...
registrasion/views.py
def invoice_access(request, access_code): ''' Redirects to an invoice for the attendee that matches the given access code, if any. If the attendee has multiple invoices, we use the following tie-break: - If there's an unpaid invoice, show that, otherwise - If there's a paid invoice, show the most ...
def invoice_access(request, access_code): ''' Redirects to an invoice for the attendee that matches the given access code, if any. If the attendee has multiple invoices, we use the following tie-break: - If there's an unpaid invoice, show that, otherwise - If there's a paid invoice, show the most ...
[ "Redirects", "to", "an", "invoice", "for", "the", "attendee", "that", "matches", "the", "given", "access", "code", "if", "any", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L690-L730
[ "def", "invoice_access", "(", "request", ",", "access_code", ")", ":", "invoices", "=", "commerce", ".", "Invoice", ".", "objects", ".", "filter", "(", "user__attendee__access_code", "=", "access_code", ",", ")", ".", "order_by", "(", "\"-issue_time\"", ")", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
invoice
Displays an invoice. This view is not authenticated, but it will only allow access to either: the user the invoice belongs to; staff; or a request made with the correct access code. Arguments: invoice_id (castable to int): The invoice_id for the invoice you want to view. ...
registrasion/views.py
def invoice(request, invoice_id, access_code=None): ''' Displays an invoice. This view is not authenticated, but it will only allow access to either: the user the invoice belongs to; staff; or a request made with the correct access code. Arguments: invoice_id (castable to int): The invoic...
def invoice(request, invoice_id, access_code=None): ''' Displays an invoice. This view is not authenticated, but it will only allow access to either: the user the invoice belongs to; staff; or a request made with the correct access code. Arguments: invoice_id (castable to int): The invoic...
[ "Displays", "an", "invoice", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L733-L775
[ "def", "invoice", "(", "request", ",", "invoice_id", ",", "access_code", "=", "None", ")", ":", "current_invoice", "=", "InvoiceController", ".", "for_id_or_404", "(", "invoice_id", ")", "if", "not", "current_invoice", ".", "can_view", "(", "user", "=", "reque...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
manual_payment
Allows staff to make manual payments or refunds on an invoice. This form requires a login, and the logged in user needs to be staff. Arguments: invoice_id (castable to int): The invoice ID to be paid Returns: render: Renders ``registrasion/manual_payment.html`` with the follow...
registrasion/views.py
def manual_payment(request, invoice_id): ''' Allows staff to make manual payments or refunds on an invoice. This form requires a login, and the logged in user needs to be staff. Arguments: invoice_id (castable to int): The invoice ID to be paid Returns: render: Renders ``r...
def manual_payment(request, invoice_id): ''' Allows staff to make manual payments or refunds on an invoice. This form requires a login, and the logged in user needs to be staff. Arguments: invoice_id (castable to int): The invoice ID to be paid Returns: render: Renders ``r...
[ "Allows", "staff", "to", "make", "manual", "payments", "or", "refunds", "on", "an", "invoice", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L784-L826
[ "def", "manual_payment", "(", "request", ",", "invoice_id", ")", ":", "FORM_PREFIX", "=", "\"manual_payment\"", "current_invoice", "=", "InvoiceController", ".", "for_id_or_404", "(", "invoice_id", ")", "form", "=", "forms", ".", "ManualPaymentForm", "(", "request",...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
refund
Marks an invoice as refunded and requests a credit note for the full amount paid against the invoice. This view requires a login, and the logged in user must be staff. Arguments: invoice_id (castable to int): The ID of the invoice to refund. Returns: redirect: Redirects to...
registrasion/views.py
def refund(request, invoice_id): ''' Marks an invoice as refunded and requests a credit note for the full amount paid against the invoice. This view requires a login, and the logged in user must be staff. Arguments: invoice_id (castable to int): The ID of the invoice to refund. Returns: ...
def refund(request, invoice_id): ''' Marks an invoice as refunded and requests a credit note for the full amount paid against the invoice. This view requires a login, and the logged in user must be staff. Arguments: invoice_id (castable to int): The ID of the invoice to refund. Returns: ...
[ "Marks", "an", "invoice", "as", "refunded", "and", "requests", "a", "credit", "note", "for", "the", "full", "amount", "paid", "against", "the", "invoice", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L830-L853
[ "def", "refund", "(", "request", ",", "invoice_id", ")", ":", "current_invoice", "=", "InvoiceController", ".", "for_id_or_404", "(", "invoice_id", ")", "try", ":", "current_invoice", ".", "refund", "(", ")", "messages", ".", "success", "(", "request", ",", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
credit_note
Displays a credit note. If ``request`` is a ``POST`` request, forms for applying or refunding a credit note will be processed. This view requires a login, and the logged in user must be staff. Arguments: note_id (castable to int): The ID of the credit note to view. Returns: rende...
registrasion/views.py
def credit_note(request, note_id, access_code=None): ''' Displays a credit note. If ``request`` is a ``POST`` request, forms for applying or refunding a credit note will be processed. This view requires a login, and the logged in user must be staff. Arguments: note_id (castable to int): T...
def credit_note(request, note_id, access_code=None): ''' Displays a credit note. If ``request`` is a ``POST`` request, forms for applying or refunding a credit note will be processed. This view requires a login, and the logged in user must be staff. Arguments: note_id (castable to int): T...
[ "Displays", "a", "credit", "note", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L857-L944
[ "def", "credit_note", "(", "request", ",", "note_id", ",", "access_code", "=", "None", ")", ":", "note_id", "=", "int", "(", "note_id", ")", "current_note", "=", "CreditNoteController", ".", "for_id_or_404", "(", "note_id", ")", "apply_form", "=", "forms", "...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
amend_registration
Allows staff to amend a user's current registration cart, and etc etc.
registrasion/views.py
def amend_registration(request, user_id): ''' Allows staff to amend a user's current registration cart, and etc etc. ''' user = User.objects.get(id=int(user_id)) current_cart = CartController.for_user(user) items = commerce.ProductItem.objects.filter( cart=current_cart.cart, ).select_r...
def amend_registration(request, user_id): ''' Allows staff to amend a user's current registration cart, and etc etc. ''' user = User.objects.get(id=int(user_id)) current_cart = CartController.for_user(user) items = commerce.ProductItem.objects.filter( cart=current_cart.cart, ).select_r...
[ "Allows", "staff", "to", "amend", "a", "user", "s", "current", "registration", "cart", "and", "etc", "etc", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L948-L1014
[ "def", "amend_registration", "(", "request", ",", "user_id", ")", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "id", "=", "int", "(", "user_id", ")", ")", "current_cart", "=", "CartController", ".", "for_user", "(", "user", ")", "items", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
extend_reservation
Allows staff to extend the reservation on a given user's cart.
registrasion/views.py
def extend_reservation(request, user_id, days=7): ''' Allows staff to extend the reservation on a given user's cart. ''' user = User.objects.get(id=int(user_id)) cart = CartController.for_user(user) cart.extend_reservation(datetime.timedelta(days=days)) return redirect(request.META["HTTP_REFER...
def extend_reservation(request, user_id, days=7): ''' Allows staff to extend the reservation on a given user's cart. ''' user = User.objects.get(id=int(user_id)) cart = CartController.for_user(user) cart.extend_reservation(datetime.timedelta(days=days)) return redirect(request.META["HTTP_REFER...
[ "Allows", "staff", "to", "extend", "the", "reservation", "on", "a", "given", "user", "s", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1018-L1026
[ "def", "extend_reservation", "(", "request", ",", "user_id", ",", "days", "=", "7", ")", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "id", "=", "int", "(", "user_id", ")", ")", "cart", "=", "CartController", ".", "for_user", "(", "user...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
invoice_mailout
Allows staff to send emails to users based on their invoice status.
registrasion/views.py
def invoice_mailout(request): ''' Allows staff to send emails to users based on their invoice status. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.InvoiceEmailForm( request.POST or None, ...
def invoice_mailout(request): ''' Allows staff to send emails to users based on their invoice status. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.InvoiceEmailForm( request.POST or None, ...
[ "Allows", "staff", "to", "send", "emails", "to", "users", "based", "on", "their", "invoice", "status", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1036-L1077
[ "def", "invoice_mailout", "(", "request", ")", ":", "category", "=", "request", ".", "GET", ".", "getlist", "(", "\"category\"", ",", "[", "]", ")", "product", "=", "request", ".", "GET", ".", "getlist", "(", "\"product\"", ",", "[", "]", ")", "status"...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
badge
Renders a single user's badge (SVG).
registrasion/views.py
def badge(request, user_id): ''' Renders a single user's badge (SVG). ''' user_id = int(user_id) user = User.objects.get(pk=user_id) rendered = render_badge(user) response = HttpResponse(rendered) response["Content-Type"] = "image/svg+xml" response["Content-Disposition"] = 'inline; filena...
def badge(request, user_id): ''' Renders a single user's badge (SVG). ''' user_id = int(user_id) user = User.objects.get(pk=user_id) rendered = render_badge(user) response = HttpResponse(rendered) response["Content-Type"] = "image/svg+xml" response["Content-Disposition"] = 'inline; filena...
[ "Renders", "a", "single", "user", "s", "badge", "(", "SVG", ")", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1081-L1092
[ "def", "badge", "(", "request", ",", "user_id", ")", ":", "user_id", "=", "int", "(", "user_id", ")", "user", "=", "User", ".", "objects", ".", "get", "(", "pk", "=", "user_id", ")", "rendered", "=", "render_badge", "(", "user", ")", "response", "=",...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
badges
Either displays a form containing a list of users with badges to render, or returns a .zip file containing their badges.
registrasion/views.py
def badges(request): ''' Either displays a form containing a list of users with badges to render, or returns a .zip file containing their badges. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.Invo...
def badges(request): ''' Either displays a form containing a list of users with badges to render, or returns a .zip file containing their badges. ''' category = request.GET.getlist("category", []) product = request.GET.getlist("product", []) status = request.GET.get("status") form = forms.Invo...
[ "Either", "displays", "a", "form", "containing", "a", "list", "of", "users", "with", "badges", "to", "render", "or", "returns", "a", ".", "zip", "file", "containing", "their", "badges", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1095-L1128
[ "def", "badges", "(", "request", ")", ":", "category", "=", "request", ".", "GET", ".", "getlist", "(", "\"category\"", ",", "[", "]", ")", "product", "=", "request", ".", "GET", ".", "getlist", "(", "\"product\"", ",", "[", "]", ")", "status", "=", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
render_badge
Renders a single user's badge.
registrasion/views.py
def render_badge(user): ''' Renders a single user's badge. ''' data = { "user": user, } t = loader.get_template('registrasion/badge.svg') return t.render(data)
def render_badge(user): ''' Renders a single user's badge. ''' data = { "user": user, } t = loader.get_template('registrasion/badge.svg') return t.render(data)
[ "Renders", "a", "single", "user", "s", "badge", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/views.py#L1131-L1139
[ "def", "render_badge", "(", "user", ")", ":", "data", "=", "{", "\"user\"", ":", "user", ",", "}", "t", "=", "loader", ".", "get_template", "(", "'registrasion/badge.svg'", ")", "return", "t", ".", "render", "(", "data", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
DiscountController.available_discounts
Returns all discounts available to this user for the given categories and products. The discounts also list the available quantity for this user, not including products that are pending purchase.
registrasion/controllers/discount.py
def available_discounts(cls, user, categories, products): ''' Returns all discounts available to this user for the given categories and products. The discounts also list the available quantity for this user, not including products that are pending purchase. ''' filtered_clauses = cls._f...
def available_discounts(cls, user, categories, products): ''' Returns all discounts available to this user for the given categories and products. The discounts also list the available quantity for this user, not including products that are pending purchase. ''' filtered_clauses = cls._f...
[ "Returns", "all", "discounts", "available", "to", "this", "user", "for", "the", "given", "categories", "and", "products", ".", "The", "discounts", "also", "list", "the", "available", "quantity", "for", "this", "user", "not", "including", "products", "that", "a...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/discount.py#L50-L101
[ "def", "available_discounts", "(", "cls", ",", "user", ",", "categories", ",", "products", ")", ":", "filtered_clauses", "=", "cls", ".", "_filtered_clauses", "(", "user", ")", "# clauses that match provided categories", "categories", "=", "set", "(", "categories", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
DiscountController._annotate_with_past_uses
Annotates the queryset with a usage count for that discount claus by the given user.
registrasion/controllers/discount.py
def _annotate_with_past_uses(cls, queryset, user): ''' Annotates the queryset with a usage count for that discount claus by the given user. ''' if queryset.model == conditions.DiscountForCategory: matches = ( Q(category=F('discount__discountitem__product__category'))...
def _annotate_with_past_uses(cls, queryset, user): ''' Annotates the queryset with a usage count for that discount claus by the given user. ''' if queryset.model == conditions.DiscountForCategory: matches = ( Q(category=F('discount__discountitem__product__category'))...
[ "Annotates", "the", "queryset", "with", "a", "usage", "count", "for", "that", "discount", "claus", "by", "the", "given", "user", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/discount.py#L166-L197
[ "def", "_annotate_with_past_uses", "(", "cls", ",", "queryset", ",", "user", ")", ":", "if", "queryset", ".", "model", "==", "conditions", ".", "DiscountForCategory", ":", "matches", "=", "(", "Q", "(", "category", "=", "F", "(", "'discount__discountitem__prod...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
ProductController.available_products
Returns a list of all of the products that are available per flag conditions from the given categories.
registrasion/controllers/product.py
def available_products(cls, user, category=None, products=None): ''' Returns a list of all of the products that are available per flag conditions from the given categories. ''' if category is None and products is None: raise ValueError("You must provide products or a category") ...
def available_products(cls, user, category=None, products=None): ''' Returns a list of all of the products that are available per flag conditions from the given categories. ''' if category is None and products is None: raise ValueError("You must provide products or a category") ...
[ "Returns", "a", "list", "of", "all", "of", "the", "products", "that", "are", "available", "per", "flag", "conditions", "from", "the", "given", "categories", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/product.py#L23-L56
[ "def", "available_products", "(", "cls", ",", "user", ",", "category", "=", "None", ",", "products", "=", "None", ")", ":", "if", "category", "is", "None", "and", "products", "is", "None", ":", "raise", "ValueError", "(", "\"You must provide products or a cate...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CreditNoteController.generate_from_invoice
Generates a credit note of the specified value and pays it against the given invoice. You need to call InvoiceController.update_status() to set the status correctly, if appropriate.
registrasion/controllers/credit_note.py
def generate_from_invoice(cls, invoice, value): ''' Generates a credit note of the specified value and pays it against the given invoice. You need to call InvoiceController.update_status() to set the status correctly, if appropriate. ''' credit_note = commerce.CreditNote.objects.create(...
def generate_from_invoice(cls, invoice, value): ''' Generates a credit note of the specified value and pays it against the given invoice. You need to call InvoiceController.update_status() to set the status correctly, if appropriate. ''' credit_note = commerce.CreditNote.objects.create(...
[ "Generates", "a", "credit", "note", "of", "the", "specified", "value", "and", "pays", "it", "against", "the", "given", "invoice", ".", "You", "need", "to", "call", "InvoiceController", ".", "update_status", "()", "to", "set", "the", "status", "correctly", "i...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/credit_note.py#L18-L31
[ "def", "generate_from_invoice", "(", "cls", ",", "invoice", ",", "value", ")", ":", "credit_note", "=", "commerce", ".", "CreditNote", ".", "objects", ".", "create", "(", "invoice", "=", "invoice", ",", "amount", "=", "0", "-", "value", ",", "# Credit note...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CreditNoteController.apply_to_invoice
Applies the total value of this credit note to the specified invoice. If this credit note overpays the invoice, a new credit note containing the residual value will be created. Raises ValidationError if the given invoice is not allowed to be paid.
registrasion/controllers/credit_note.py
def apply_to_invoice(self, invoice): ''' Applies the total value of this credit note to the specified invoice. If this credit note overpays the invoice, a new credit note containing the residual value will be created. Raises ValidationError if the given invoice is not allowed to be ...
def apply_to_invoice(self, invoice): ''' Applies the total value of this credit note to the specified invoice. If this credit note overpays the invoice, a new credit note containing the residual value will be created. Raises ValidationError if the given invoice is not allowed to be ...
[ "Applies", "the", "total", "value", "of", "this", "credit", "note", "to", "the", "specified", "invoice", ".", "If", "this", "credit", "note", "overpays", "the", "invoice", "a", "new", "credit", "note", "containing", "the", "residual", "value", "will", "be", ...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/credit_note.py#L34-L56
[ "def", "apply_to_invoice", "(", "self", ",", "invoice", ")", ":", "# Local import to fix import cycles. Can we do better?", "from", ".", "invoice", "import", "InvoiceController", "inv", "=", "InvoiceController", "(", "invoice", ")", "inv", ".", "validate_allowed_to_pay", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
CreditNoteController.cancellation_fee
Generates an invoice with a cancellation fee, and applies credit to the invoice. percentage (Decimal): The percentage of the credit note to turn into a cancellation fee. Must be 0 <= percentage <= 100.
registrasion/controllers/credit_note.py
def cancellation_fee(self, percentage): ''' Generates an invoice with a cancellation fee, and applies credit to the invoice. percentage (Decimal): The percentage of the credit note to turn into a cancellation fee. Must be 0 <= percentage <= 100. ''' # Local import to fi...
def cancellation_fee(self, percentage): ''' Generates an invoice with a cancellation fee, and applies credit to the invoice. percentage (Decimal): The percentage of the credit note to turn into a cancellation fee. Must be 0 <= percentage <= 100. ''' # Local import to fi...
[ "Generates", "an", "invoice", "with", "a", "cancellation", "fee", "and", "applies", "credit", "to", "the", "invoice", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/credit_note.py#L60-L83
[ "def", "cancellation_fee", "(", "self", ",", "percentage", ")", ":", "# Local import to fix import cycles. Can we do better?", "from", ".", "invoice", "import", "InvoiceController", "assert", "(", "percentage", ">=", "0", "and", "percentage", "<=", "100", ")", "cancel...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
generate_access_code
Generates an access code for users' payments as well as their fulfilment code for check-in. The access code will 4 characters long, which allows for 1,500,625 unique codes, which really should be enough for anyone.
registrasion/util.py
def generate_access_code(): ''' Generates an access code for users' payments as well as their fulfilment code for check-in. The access code will 4 characters long, which allows for 1,500,625 unique codes, which really should be enough for anyone. ''' length = 6 # all upper-case letters + digits...
def generate_access_code(): ''' Generates an access code for users' payments as well as their fulfilment code for check-in. The access code will 4 characters long, which allows for 1,500,625 unique codes, which really should be enough for anyone. ''' length = 6 # all upper-case letters + digits...
[ "Generates", "an", "access", "code", "for", "users", "payments", "as", "well", "as", "their", "fulfilment", "code", "for", "check", "-", "in", ".", "The", "access", "code", "will", "4", "characters", "long", "which", "allows", "for", "1", "500", "625", "...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/util.py#L7-L17
[ "def", "generate_access_code", "(", ")", ":", "length", "=", "6", "# all upper-case letters + digits 1-9 (no 0 vs O confusion)", "chars", "=", "string", ".", "uppercase", "+", "string", ".", "digits", "[", "1", ":", "]", "# 6 chars => 35 ** 6 = 1838265625 (should be enoug...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
lazy
Produces a callable so that functions can be lazily evaluated in templates. Arguments: function (callable): The function to call at evaluation time. args: Positional arguments, passed directly to ``function``. kwargs: Keyword arguments, passed directly to ``function``. Return: ...
registrasion/util.py
def lazy(function, *args, **kwargs): ''' Produces a callable so that functions can be lazily evaluated in templates. Arguments: function (callable): The function to call at evaluation time. args: Positional arguments, passed directly to ``function``. kwargs: Keyword arguments, pa...
def lazy(function, *args, **kwargs): ''' Produces a callable so that functions can be lazily evaluated in templates. Arguments: function (callable): The function to call at evaluation time. args: Positional arguments, passed directly to ``function``. kwargs: Keyword arguments, pa...
[ "Produces", "a", "callable", "so", "that", "functions", "can", "be", "lazily", "evaluated", "in", "templates", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/util.py#L31-L58
[ "def", "lazy", "(", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "NOT_EVALUATED", "=", "object", "(", ")", "retval", "=", "[", "NOT_EVALUATED", "]", "def", "evaluate", "(", ")", ":", "if", "retval", "[", "0", "]", "is", "NOT_EVA...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
get_object_from_name
Returns the named object. Arguments: name (str): A string of form `package.subpackage.etc.module.property`. This function will import `package.subpackage.etc.module` and return `property` from that module.
registrasion/util.py
def get_object_from_name(name): ''' Returns the named object. Arguments: name (str): A string of form `package.subpackage.etc.module.property`. This function will import `package.subpackage.etc.module` and return `property` from that module. ''' dot = name.rindex(".") ...
def get_object_from_name(name): ''' Returns the named object. Arguments: name (str): A string of form `package.subpackage.etc.module.property`. This function will import `package.subpackage.etc.module` and return `property` from that module. ''' dot = name.rindex(".") ...
[ "Returns", "the", "named", "object", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/util.py#L61-L74
[ "def", "get_object_from_name", "(", "name", ")", ":", "dot", "=", "name", ".", "rindex", "(", "\".\"", ")", "mod_name", ",", "property_name", "=", "name", "[", ":", "dot", "]", ",", "name", "[", "dot", "+", "1", ":", "]", "__import__", "(", "mod_name...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController.for_cart
Returns an invoice object for a given cart at its current revision. If such an invoice does not exist, the cart is validated, and if valid, an invoice is generated.
registrasion/controllers/invoice.py
def for_cart(cls, cart): ''' Returns an invoice object for a given cart at its current revision. If such an invoice does not exist, the cart is validated, and if valid, an invoice is generated.''' cart.refresh_from_db() try: invoice = commerce.Invoice.objects.exclude...
def for_cart(cls, cart): ''' Returns an invoice object for a given cart at its current revision. If such an invoice does not exist, the cart is validated, and if valid, an invoice is generated.''' cart.refresh_from_db() try: invoice = commerce.Invoice.objects.exclude...
[ "Returns", "an", "invoice", "object", "for", "a", "given", "cart", "at", "its", "current", "revision", ".", "If", "such", "an", "invoice", "does", "not", "exist", "the", "cart", "is", "validated", "and", "if", "valid", "an", "invoice", "is", "generated", ...
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L28-L48
[ "def", "for_cart", "(", "cls", ",", "cart", ")", ":", "cart", ".", "refresh_from_db", "(", ")", "try", ":", "invoice", "=", "commerce", ".", "Invoice", ".", "objects", ".", "exclude", "(", "status", "=", "commerce", ".", "Invoice", ".", "STATUS_VOID", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController.manual_invoice
Generates an invoice for arbitrary items, not held in a user's cart. Arguments: user (User): The user the invoice is being generated for. due_delta (datetime.timedelta): The length until the invoice is due. description_price_pairs ([(str, long or Deci...
registrasion/controllers/invoice.py
def manual_invoice(cls, user, due_delta, description_price_pairs): ''' Generates an invoice for arbitrary items, not held in a user's cart. Arguments: user (User): The user the invoice is being generated for. due_delta (datetime.timedelta): The length until the invoice i...
def manual_invoice(cls, user, due_delta, description_price_pairs): ''' Generates an invoice for arbitrary items, not held in a user's cart. Arguments: user (User): The user the invoice is being generated for. due_delta (datetime.timedelta): The length until the invoice i...
[ "Generates", "an", "invoice", "for", "arbitrary", "items", "not", "held", "in", "a", "user", "s", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L76-L104
[ "def", "manual_invoice", "(", "cls", ",", "user", ",", "due_delta", ",", "description_price_pairs", ")", ":", "line_items", "=", "[", "]", "for", "description", ",", "price", "in", "description_price_pairs", ":", "line_item", "=", "commerce", ".", "LineItem", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController._generate_from_cart
Generates an invoice for the given cart.
registrasion/controllers/invoice.py
def _generate_from_cart(cls, cart): ''' Generates an invoice for the given cart. ''' cart.refresh_from_db() # Generate the line items from the cart. product_items = commerce.ProductItem.objects.filter(cart=cart) product_items = product_items.select_related( "produc...
def _generate_from_cart(cls, cart): ''' Generates an invoice for the given cart. ''' cart.refresh_from_db() # Generate the line items from the cart. product_items = commerce.ProductItem.objects.filter(cart=cart) product_items = product_items.select_related( "produc...
[ "Generates", "an", "invoice", "for", "the", "given", "cart", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L108-L165
[ "def", "_generate_from_cart", "(", "cls", ",", "cart", ")", ":", "cart", ".", "refresh_from_db", "(", ")", "# Generate the line items from the cart.", "product_items", "=", "commerce", ".", "ProductItem", ".", "objects", ".", "filter", "(", "cart", "=", "cart", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController._apply_credit_notes
Applies the user's credit notes to the given invoice on creation.
registrasion/controllers/invoice.py
def _apply_credit_notes(cls, invoice): ''' Applies the user's credit notes to the given invoice on creation. ''' # We only automatically apply credit notes if this is the *only* # unpaid invoice for this user. invoices = commerce.Invoice.objects.filter( user=invoice....
def _apply_credit_notes(cls, invoice): ''' Applies the user's credit notes to the given invoice on creation. ''' # We only automatically apply credit notes if this is the *only* # unpaid invoice for this user. invoices = commerce.Invoice.objects.filter( user=invoice....
[ "Applies", "the", "user", "s", "credit", "notes", "to", "the", "given", "invoice", "on", "creation", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L206-L229
[ "def", "_apply_credit_notes", "(", "cls", ",", "invoice", ")", ":", "# We only automatically apply credit notes if this is the *only*", "# unpaid invoice for this user.", "invoices", "=", "commerce", ".", "Invoice", ".", "objects", ".", "filter", "(", "user", "=", "invoic...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController.can_view
Returns true if the accessing user is allowed to view this invoice, or if the given access code matches this invoice's user's access code.
registrasion/controllers/invoice.py
def can_view(self, user=None, access_code=None): ''' Returns true if the accessing user is allowed to view this invoice, or if the given access code matches this invoice's user's access code. ''' if user == self.invoice.user: return True if user.is_staff: ...
def can_view(self, user=None, access_code=None): ''' Returns true if the accessing user is allowed to view this invoice, or if the given access code matches this invoice's user's access code. ''' if user == self.invoice.user: return True if user.is_staff: ...
[ "Returns", "true", "if", "the", "accessing", "user", "is", "allowed", "to", "view", "this", "invoice", "or", "if", "the", "given", "access", "code", "matches", "this", "invoice", "s", "user", "s", "access", "code", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L231-L245
[ "def", "can_view", "(", "self", ",", "user", "=", "None", ",", "access_code", "=", "None", ")", ":", "if", "user", "==", "self", ".", "invoice", ".", "user", ":", "return", "True", "if", "user", ".", "is_staff", ":", "return", "True", "if", "self", ...
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController._refresh
Refreshes the underlying invoice and cart objects.
registrasion/controllers/invoice.py
def _refresh(self): ''' Refreshes the underlying invoice and cart objects. ''' self.invoice.refresh_from_db() if self.invoice.cart: self.invoice.cart.refresh_from_db()
def _refresh(self): ''' Refreshes the underlying invoice and cart objects. ''' self.invoice.refresh_from_db() if self.invoice.cart: self.invoice.cart.refresh_from_db()
[ "Refreshes", "the", "underlying", "invoice", "and", "cart", "objects", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L247-L251
[ "def", "_refresh", "(", "self", ")", ":", "self", ".", "invoice", ".", "refresh_from_db", "(", ")", "if", "self", ".", "invoice", ".", "cart", ":", "self", ".", "invoice", ".", "cart", ".", "refresh_from_db", "(", ")" ]
461d5846c6f9f3b7099322a94f5d9911564448e4
test
InvoiceController.validate_allowed_to_pay
Passes cleanly if we're allowed to pay, otherwise raise a ValidationError.
registrasion/controllers/invoice.py
def validate_allowed_to_pay(self): ''' Passes cleanly if we're allowed to pay, otherwise raise a ValidationError. ''' self._refresh() if not self.invoice.is_unpaid: raise ValidationError("You can only pay for unpaid invoices.") if not self.invoice.cart: ...
def validate_allowed_to_pay(self): ''' Passes cleanly if we're allowed to pay, otherwise raise a ValidationError. ''' self._refresh() if not self.invoice.is_unpaid: raise ValidationError("You can only pay for unpaid invoices.") if not self.invoice.cart: ...
[ "Passes", "cleanly", "if", "we", "re", "allowed", "to", "pay", "otherwise", "raise", "a", "ValidationError", "." ]
chrisjrn/registrasion
python
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/controllers/invoice.py#L253-L269
[ "def", "validate_allowed_to_pay", "(", "self", ")", ":", "self", ".", "_refresh", "(", ")", "if", "not", "self", ".", "invoice", ".", "is_unpaid", ":", "raise", "ValidationError", "(", "\"You can only pay for unpaid invoices.\"", ")", "if", "not", "self", ".", ...
461d5846c6f9f3b7099322a94f5d9911564448e4