Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ coverage.xml
# Sphinx documentation
docs/_build/

# Migrations added by Django framework
website/control/migrations/

# Pycharm default folder
.idea
61 changes: 60 additions & 1 deletion common/api/maindb.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@
from clearinghouse.website.control.models import ActionLogEvent
from clearinghouse.website.control.models import ActionLogVesselDetails


from clearinghouse.website.control.models import Experiment
from clearinghouse.website.control.models import Battery
from clearinghouse.website.control.models import Bluetooth
from clearinghouse.website.control.models import Cellular
from clearinghouse.website.control.models import Location
from clearinghouse.website.control.models import Settings
from clearinghouse.website.control.models import ConcretSensor
from clearinghouse.website.control.models import Signal_strengths
from clearinghouse.website.control.models import Wifi



Expand Down Expand Up @@ -244,6 +252,57 @@ def create_user(username, password, email, affiliation, user_pubkey, user_privke



def create_experiment(geni_user,experiment_name,researcher_name,researcher_address ,researcher_email, irb_name,irb_email, experiment_goal):
"""
<Purpose>
Create a new experiment in the database.

<Arguments>
geni_user
experiment_name
researcher_name
researcher_address
researcher_email
irb_name
irb_email
experiment_goal

<Exceptions>
None

<Side Effects>
Creates a experiment record in the django experiment table.
Does not change the database if creation of either record fails.

<Returns>
A GeniUser object of the newly created user.
"""
assert_str(experiment_name)
assert_str(researcher_name)
assert_str(researcher_address)
assert_str(researcher_email)
assert_str(irb_name)
assert_str(irb_email)
assert_str(experiment_goal)

# We're committing manually to make sure the multiple database writes are
# atomic. (That is, regenerate_api_key() will do a database write.)
try:
with transaction.atomic():
# Create the Experiment
experiment = Experiment(expe_name=experiment_name, geni_user=geni_user,
researcher_name=researcher_name, researcher_institution_name = irb_name,
researcher_email=researcher_email, researcher_address=researcher_address,
irb_officer_email=irb_email, goal=experiment_goal)
experiment.save()
except:
transaction.rollback()
raise

else:
transaction.commit()

return experiment


@log_function_call
Expand Down
16 changes: 8 additions & 8 deletions website/context_processor.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def customizable_strings(request):
from django.conf import settings
return {
"TESTBED": settings.TESTBED,
"TESTBED_URL": settings.TESTBED_URL,
"TESTBED_DEVELOPERS_MAIL": settings.TESTBED_DEVELOPERS_MAIL,
"TESTBED_USERS_MAIL": settings.TESTBED_USERS_MAIL,
"CLEARINGHOUSE": settings.CLEARINGHOUSE,
"CLEARINGHOUSE_URL": settings.CLEARINGHOUSE_URL,
"DEMOKIT": settings.DEMOKIT,
}
"TESTBED": settings.TESTBED,
"TESTBED_URL": settings.TESTBED_URL,
"TESTBED_DEVELOPERS_MAIL": settings.TESTBED_DEVELOPERS_MAIL,
"TESTBED_USERS_MAIL": settings.TESTBED_USERS_MAIL,
"CLEARINGHOUSE": settings.CLEARINGHOUSE,
"CLEARINGHOUSE_URL": settings.CLEARINGHOUSE_URL,
"DEMOKIT": settings.DEMOKIT,
}
76 changes: 23 additions & 53 deletions website/control/admin.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from models import ActionLogEvent
from models import ActionLogVesselDetails


from django.contrib import admin
from django.contrib.auth.forms import AdminPasswordChangeForm
from django.contrib import messages
Expand All @@ -39,15 +38,13 @@
from django.utils.translation import ugettext, ugettext_lazy as _




class GeniUserAdmin(admin.ModelAdmin):
"""Customized admin view of the GeniUser model."""

# Use django's admin change password form
change_password_form = AdminPasswordChangeForm

list_display = ["username", "affiliation", "email", "free_vessel_credits",
list_display = ["username", "affiliation", "email", "free_vessel_credits",
"usable_vessel_port", "date_created", "is_staff",
"is_superuser"]
list_filter = ["free_vessel_credits", "date_created", "is_staff",
Expand All @@ -57,19 +54,15 @@ class GeniUserAdmin(admin.ModelAdmin):
search_fields = ["username", "user_pubkey", "donor_pubkey", "email",
"affiliation"]
ordering = ["-date_created"]



def get_urls(self):
from django.conf.urls import patterns

# Assign handler for the password change url
return patterns('',
(r'^(\d+)/password/$',
self.admin_site.admin_view(self.user_change_password))
) + super(GeniUserAdmin, self).get_urls()


(r'^(\d+)/password/$',
self.admin_site.admin_view(self.user_change_password))
) + super(GeniUserAdmin, self).get_urls()

def user_change_password(self, request, id):
if not self.has_change_permission(request):
Expand All @@ -96,26 +89,23 @@ def user_change_password(self, request, id):
# following tags. They are mostly used for deciding what elements are to be
# shown on the form.
return render_to_response('admin/auth/user/change_password.html', {
'title': _('Change password: %s') % escape(user.username),
'adminForm': adminForm,
'form': form,
'is_popup': '_popup' in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
'has_change_permission': True,
'has_absolute_url': False,
'opts': self.model._meta,
'original': user,
'save_as': False,
'show_save': True,
'root_path': self.admin_site.root_path,
'title': _('Change password: %s') % escape(user.username),
'adminForm': adminForm,
'form': form,
'is_popup': '_popup' in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
'has_change_permission': True,
'has_absolute_url': False,
'opts': self.model._meta,
'original': user,
'save_as': False,
'show_save': True,
'root_path': self.admin_site.root_path,
}, context_instance=RequestContext(request))





def partial_node_identifier(node):
"""Used by class NodeAdmin."""
return node.node_identifier[:16]
Expand All @@ -128,6 +118,8 @@ def is_ok(node):
"not broken" field where a green checkmark means it's not broken.
"""
return not node.is_broken


# Set a boolean attribute of the function itself which tells django to use the
# boolean icons to represent this field.
is_ok.boolean = True
Expand All @@ -146,7 +138,7 @@ def donor(node):
for donation in donation_list:
donor_names_list.append(donation.donor.username)
return ",".join(donor_names_list)


class NodeAdmin(admin.ModelAdmin):
"""Customized admin view of the Node model."""
Expand All @@ -160,9 +152,6 @@ class NodeAdmin(admin.ModelAdmin):
ordering = ["-date_created"]





class DonationAdmin(admin.ModelAdmin):
"""Customized admin view of the Donation model."""
list_display = ["node", "donor", "date_created"]
Expand All @@ -171,9 +160,6 @@ class DonationAdmin(admin.ModelAdmin):
ordering = ["-date_created"]





class VesselAdmin(admin.ModelAdmin):
"""Customized admin view of the Vessel model."""
list_display = ["node", "name", "acquired_by_user", "date_acquired",
Expand All @@ -184,9 +170,6 @@ class VesselAdmin(admin.ModelAdmin):
ordering = ["-date_acquired"]





class VesselPortAdmin(admin.ModelAdmin):
"""Customized admin view of the VesselPort model."""
list_display = ["vessel", "port"]
Expand All @@ -195,9 +178,6 @@ class VesselPortAdmin(admin.ModelAdmin):
"vessel__node__last_known_ip", "port"]





class VesselUserAccessMapAdmin(admin.ModelAdmin):
"""Customized admin view of the VesselUserAccessMap model."""
list_display = ["vessel", "user", "date_created"]
Expand All @@ -207,12 +187,9 @@ class VesselUserAccessMapAdmin(admin.ModelAdmin):
ordering = ["-date_created"]





class ActionLogEventAdmin(admin.ModelAdmin):
"""Customized admin view of the ActionLogEvent model."""

list_display = ["function_name", "user", "second_arg", "third_arg",
"was_successful", "message", "vessel_count", "date_started",
"completion_time"]
Expand All @@ -222,20 +199,14 @@ class ActionLogEventAdmin(admin.ModelAdmin):
ordering = ["-date_started"]





class ActionLogVesselDetailsAdmin(admin.ModelAdmin):
"""Customized admin view of the ActionLogVesselDetails model."""

list_display = ["event", "node", "node_address", "node_port", "vessel_name"]
search_fields = ["node_address"]
ordering = ["-event"]





# Register/associate each custom admin view defined above with the
# corresponding model defined in clearinghouse.website.control.models
admin.site.register(GeniUser, GeniUserAdmin)
Expand All @@ -246,4 +217,3 @@ class ActionLogVesselDetailsAdmin(admin.ModelAdmin):
admin.site.register(VesselUserAccessMap, VesselUserAccessMapAdmin)
admin.site.register(ActionLogEvent, ActionLogEventAdmin)
admin.site.register(ActionLogVesselDetails, ActionLogVesselDetailsAdmin)

Loading