Package expedient :: Package clearinghouse :: Package aggregate :: Module models :: Class Aggregate
[hide private]
[frames] | no frames]

Class Aggregate

source code


Holds information about an aggregate. Needs to be extended by plugins.

Nested Classes [hide private]
  Meta
  DoesNotExist
  Extend
  MultipleObjectsReturned

Inherited from common.extendable.models.Extendable: __metaclass__

Instance Methods [hide private]
 
save(self, *args, **kwargs)
Override the default save method to enforce permissions.
source code
 
delete(self, *args, **kwargs)
Override the default delete method to enforce permissions.
source code
 
__unicode__(self) source code
 
_get_managers(self)
Gets the list of users who have the "can_edit_aggregate" permission for this aggregate as a QuerySet of User objects.
source code
 
_get_slice_set(self)
Gets the list of slices allowed to use the aggregate
source code
 
check_status(self)
Checks whether the aggregate is available or not.
source code
 
get_logo_url(self) source code
 
get_edit_url(self)
Get the url of where to go to edit the aggregate
source code
 
get_delete_url(self, next)
Get the URL to use when deleting the project from the Aggregate List.
source code
 
add_to_project(self, project, next)
Gives the aggregate a chance to request additional information for a project.
source code
 
remove_from_project(self, project, next)
Similar to add_to_project but does the reverse, deleting the permission from the project using:
source code
 
add_to_slice(self, slice, next)
Works exactly the same as add_to_project but for a slice.
source code
 
remove_from_slice(self, slice, next)
Works exactly the same as remove_from_project but for a slice.
source code
 
add_to_user(self, user, next)
Works exactly the same as add_to_project but for a user.
source code
 
remove_from_user(self, user, next)
Works exactly the same as remove_from_project but for a user.
source code
 
start_slice(self, slice)
Start the slice in the actual resources.
source code
 
stop_slice(self, slice)
Take out the resource reservation from the aggregates.
source code
 
_base_manager(...)
 
objects(...)

Inherited from common.extendable.models.Extendable: __init__, as_leaf_class, is_instance_of

Inherited from django.db.models.base.Model: __eq__, __hash__, __ne__, __reduce__, __repr__, __str__, clean, clean_fields, date_error_message, full_clean, prepare_database_save, save_base, serializable_value, unique_error_message, validate_unique

Inherited from django.db.models.base.Model (private): _collect_sub_objects, _get_FIELD_display, _get_next_or_previous_by_FIELD, _get_next_or_previous_in_order, _get_pk_val, _get_unique_checks, _perform_date_checks, _perform_unique_checks, _set_pk_val

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
 
get_url_name_prefix(cls)
Get the prefix to append to the beginning of url names when getting default urls.
source code
 
get_aggregates_url(cls)
Get the URL for aggregates of this type
source code
 
get_create_url(cls)
Get the URL to create aggregates of this type
source code
Class Variables [hide private]
  information = '\nNo information available.\n'
Information about the aggregate.
  _default_manager = <expedient.common.extendable.models.Extenda...
  _meta = <Options for Aggregate>
  dummyaggregate = <django.db.models.fields.related.SingleRelate...
  geniaggregate = <django.db.models.fields.related.SingleRelated...
  openflowaggregate = <django.db.models.fields.related.SingleRel...
  resource_set = <django.db.models.fields.related.ForeignRelated...

Inherited from common.extendable.models.Extendable: leaf_name, module_name

Inherited from django.db.models.base.Model (private): _deferred

Instance Variables [hide private]
str name = models.CharField(max_length= 200, unique= True, help_te...
human-readable name of the Aggregate
models.ImageField logo = models.ImageField('Logo', upload_to= settings.AGGREGATE...
Logo for the aggregate (an uploaded file).
Text Field description = models.TextField(default= "")
Description of this aggregate
a string that is understandable by Google Maps. location = models.CharField("Geographic Location", max_length=...
The location of the aggregate.
bool available = models.BooleanField("Available", default= True, he...
Is the aggregate available for use?
QuerySet of Users. managers
A read-only property that returns a queryset of all user allowed to edit the aggregate (i.e.
QuerySet of Slices. slice_set
A read-only property that returns a queryset of all slices allowed to use the aggregate (i.e.
Properties [hide private]

Inherited from django.db.models.base.Model: pk

Inherited from object: __class__

Method Details [hide private]

save(self, *args, **kwargs)

source code 

Override the default save method to enforce permissions.

Overrides: django.db.models.base.Model.save

delete(self, *args, **kwargs)

source code 

Override the default delete method to enforce permissions.

Overrides: django.db.models.base.Model.delete

check_status(self)

source code 

Checks whether the aggregate is available or not.

Returns:
True if the aggregate is available, False otherwise.

get_url_name_prefix(cls)
Class Method

source code 

Get the prefix to append to the beginning of url names when getting default urls.

By default this returns the application name.

get_delete_url(self, next)

source code 

Get the URL to use when deleting the project from the Aggregate List. This function will first check if there is a URL defined as <app_label>_aggregate_delete and return that if it exists, attaching "?next=<next>" to the end of the URL.

Parameters:
  • next - URL to redirect to after deleting object.
Returns:
URL to go to when requesting the aggregate be deleted.

add_to_project(self, project, next)

source code 

Gives the aggregate a chance to request additional information for a project. This method should return a URL to redirect to where the user can create or update the additional information the aggregate needs. When done, the view at that URL should use the give_permission function to give the project the "can_use_aggregate" permission:

   from expedient.common.permissions.shortcuts import                 give_permission_to
   
   give_permission_to("can_use_aggregate", self.as_leaf_class(), project)

and then it should redirect to next.

If no extra information is needed, this function can return next, instead of a custom URL, but it still needs to give the project the "can_use_aggregate" permission.

Unless overridden in a subclass, this function will look for a url with name <app_name>_aggregate_project_add by reversing the name with it parameters 'agg_id' and 'proj_id'. It will append '?next=<next>' to the URL if found. Otherwise, it simply gives the permission to the project and returns next.

remove_from_project(self, project, next)

source code 

Similar to add_to_project but does the reverse, deleting the permission from the project using:

   from expedient.common.permissions.shortcuts import                 delete_permission
       
   delete_permission("can_use_aggregate", self.as_leaf_class(), project)

and then redirecting to next. Additionally, if not overridden, this function stops all slices in the project before removing the aggregate. Subclasses should also stop slices.

remove_from_slice(self, slice, next)

source code 

Works exactly the same as remove_from_project but for a slice. It stops the slice if not overridden. Subclasses should stop the slice before removing the permission.

remove_from_user(self, user, next)

source code 

Works exactly the same as remove_from_project but for a user. Does not stop any slices.

start_slice(self, slice)

source code 

Start the slice in the actual resources.

Subclasses overriding this method should call the parent class to ensure permission checks.

stop_slice(self, slice)

source code 

Take out the resource reservation from the aggregates.

Subclasses overriding this method should call the parent class to ensure permission checks.

objects(...)

 
Overrides: common.extendable.models.Extendable.objects

Class Variable Details [hide private]

information

Information about the aggregate. Used when displaying information about the type. Should be overriden.
Value:
'''
No information available.
'''

_default_manager

Value:
<expedient.common.extendable.models.ExtendableManager object at 0x8d6d\
0ec>

dummyaggregate

Value:
<django.db.models.fields.related.SingleRelatedObjectDescriptor object \
at 0x9a544cc>

geniaggregate

Value:
<django.db.models.fields.related.SingleRelatedObjectDescriptor object \
at 0x8fafacc>

openflowaggregate

Value:
<django.db.models.fields.related.SingleRelatedObjectDescriptor object \
at 0x8f74b8c>

resource_set

Value:
<django.db.models.fields.related.ForeignRelatedObjectsDescriptor objec\
t at 0x8d891ac>

Instance Variable Details [hide private]

name

human-readable name of the Aggregate
Type:
str
Value:
models.CharField(max_length= 200, unique= True, help_text= "Use a uniq\
ue name for this aggregate.")

logo

Logo for the aggregate (an uploaded file).
Type:
models.ImageField
Value:
models.ImageField('Logo', upload_to= settings.AGGREGATE_LOGOS_DIR, edi\
table= False, blank= True, null= True, help_text= "Select an optional \
logo.")

location

The location of the aggregate.
Type:
a string that is understandable by Google Maps.
Value:
models.CharField("Geographic Location", max_length= 200, default= "", \
help_text= "This should be a location that can be found using " "Googl\
e Maps")

available

Is the aggregate available for use?
Type:
bool
Value:
models.BooleanField("Available", default= True, help_text= "Do you wan\
t to make this\
 aggregate available for others to use?")

managers

A read-only property that returns a queryset of all user allowed to edit the aggregate (i.e. have the "can_edit_aggregate" permission for this aggregate).
Get Method:
_get_managers(self) - Gets the list of users who have the "can_edit_aggregate" permission for this aggregate as a QuerySet of User objects.

slice_set

A read-only property that returns a queryset of all slices allowed to use the aggregate (i.e. have the "can_use_aggregate" permission for this aggregate).
Get Method:
_get_slice_set(self) - Gets the list of slices allowed to use the aggregate