Skip to content

Commit

Permalink
Merge branch 'dashboard-angular' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
flekschas committed Jun 29, 2015
2 parents 1e9a373 + 01476f8 commit 571faaa
Show file tree
Hide file tree
Showing 65 changed files with 2,306 additions and 723 deletions.
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network "private_network", ip: "192.168.50.50"

config.vm.provider "virtualbox" do |v|
v.memory = 1280
v.memory = 1024
v.cpus = 1
end

Expand Down
3 changes: 2 additions & 1 deletion refinery/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from sets import Set
from django.conf.urls.defaults import url
from django.contrib.auth.models import User, Group
from guardian.shortcuts import get_objects_for_user, get_objects_for_group
from guardian.shortcuts import get_objects_for_user, get_objects_for_group, \
get_perms
from tastypie import fields
from tastypie.authentication import SessionAuthentication, Authentication
from tastypie.authorization import Authorization
Expand Down
41 changes: 20 additions & 21 deletions refinery/core/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

class DataSetIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
# id of the user who owns this project
owner_id = indexes.CharField()
# ids of the groups who have read permission for this data set
group_ids = indexes.MultiValueField(null=True)
name = indexes.CharField(model_attr='name', null=True)
title = indexes.CharField(null=True)
uuid = indexes.CharField(model_attr='uuid')
Expand All @@ -34,6 +30,10 @@ class DataSetIndex(indexes.SearchIndex, indexes.Indexable):
measurement = indexes.MultiValueField(null=True, faceted=True)
technology = indexes.MultiValueField(null=True, faceted=True)

# We only need one multi value field to story every id that has access since
# Solr only handles read permissions.
access = indexes.MultiValueField(null=True)

# We add this for autocomplete.
content_auto = indexes.EdgeNgramField(null=True)

Expand All @@ -53,14 +53,13 @@ def prepare_title(self, object):
def prepare_content_auto(self, object):
return object.get_investigation().get_title()

def prepare_owner_id(self, object):
if object.get_owner() is None:
return None

return object.get_owner().id

def prepare_group_ids(self, object):
return [g["id"] for g in object.get_groups()]
def prepare_access(self, object):
access_list = []
if object.get_owner() is not None:
access_list.append('u_{}'.format(object.get_owner().id))
for group_id in object.get_group_ids():
access_list.append('g_{}'.format(group_id))
return access_list

def prepare_submitter(self, object):
investigation = object.get_investigation()
Expand Down Expand Up @@ -174,10 +173,7 @@ def prepare(self, data_set):

class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
# id of the user who owns this project
owner_id = indexes.CharField()
# ids of the groups who have read permission for this data set
group_ids = indexes.MultiValueField(null=True)
access = indexes.MultiValueField(null=True)
name = indexes.CharField(model_attr='name', null=True)
uuid = indexes.CharField(model_attr='uuid')
summary = indexes.CharField(model_attr='summary')
Expand All @@ -192,11 +188,14 @@ class ProjectIndex(indexes.SearchIndex, indexes.Indexable):
def get_model(self):
return Project

def prepare_owner_id(self, object):
return object.get_owner().id

def prepare_group_ids(self, object):
return [g["id"] for g in object.get_groups()]
def prepare_access(self, object):
access_list = []
if object.get_owner() is not None:
access_list.append('u_{}'.format(object.get_owner().id))
for group in object.get_groups():
if id in group:
access_list.append('g_{}'.format(group.id))
return access_list

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
Expand Down
28 changes: 17 additions & 11 deletions refinery/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from django.conf.urls.defaults import patterns, url


urlpatterns = patterns('core.views',
url(r'^$', 'home', name="home" ),
url(r'^about/$', 'about', name="about" ),
url(r'^contact/$', 'contact', name="contact" ),
url(r'^statistics/$', 'statistics', name="statistics" ),
urlpatterns = patterns(
'core.views',
url(r'^$', 'home', name="home"),
url(r'^about/$', 'about', name="about"),
url(r'^contact/$', 'contact', name="contact"),
url(r'^statistics/$', 'statistics', name="statistics"),
url(r'^users/(?P<query>[\@\.\-\+a-z0-9]+)/$', 'user'),
# "name" is required for use with the url tag in templates
# "name" is required for use with the url tag in templates
url(r'^users/(?P<query>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', 'user', name="user"),
url(r'^users/(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/edit/$', 'user_edit', name="user_edit"),
url(r'^groups/(?P<query>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', 'group', name="group"),
Expand All @@ -30,14 +31,19 @@
url(r'^data_sets/(?P<slug>[a-zA-Z0-9\_]+)/$', 'data_set_slug', name="data_set_slug"),
url(r'^workflows/(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', 'workflow', name="workflow"),
url(r'^workflows/(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/edit/$', 'workflow_edit', name="workflow_edit"),
url(r'^workflows/(?P<slug>[a-zA-Z0-9\_]+)/$', 'workflow_slug', name="workflow_slug"),
url(r'^workflows/(?P<slug>[a-zA-Z0-9\_]+)/$', 'workflow_slug', name="workflow_slug"),
url(r'^workflow_engines/(?P<uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', 'workflow_engine', name="workflow_engine"),

url(r'^data_sets/(?P<ds_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/samples/(?P<study_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/(?P<assay_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$', 'samples', name="samples"),

url(r'^solr/igv/$', 'solr_igv' ),

url(r'^solr/igv/$', 'solr_igv'),
url(
r'^solr/core/select/$',
'solr_core_search',
name="solr_core_search"
),
url(r'^solr/(?P<core>.+)/select/$', 'solr_select', name="solr_select"),

# test solr/search view
url(r'^data_sets/(?P<ds_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/samples/(?P<study_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/(?P<assay_uuid>[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/solr$', 'samples_solr', name="samples"),
)
Expand All @@ -54,6 +60,6 @@ def get_queryset(self):
context_object_name='datasets',
paginate_by=15,
template_name='core/data_sets.html'
))
))
)
"""
10 changes: 10 additions & 0 deletions refinery/core/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logging
from core.models import DataSet, Project
from core.search_indexes import DataSetIndex

logger = logging.getLogger(__name__)


def update_data_set_index():
data_set_index = DataSetIndex()
data_set_index.update_object(data_set, using="core")

0 comments on commit 571faaa

Please sign in to comment.