Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
mark read lengths as obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
risufaj committed Dec 5, 2018
1 parent 6d1c0e0 commit b319a93
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 8 deletions.
16 changes: 15 additions & 1 deletion library_sample_shared/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,21 @@ class ConcentrationMethodAdmin(admin.ModelAdmin):

@admin.register(ReadLength)
class ReadLengthAdmin(admin.ModelAdmin):
pass
list_display = ('name','obsolete_name')
actions = ('mark_as_obsolete','mark_as_non_obsolete')

def mark_as_obsolete(self,request,queryset):
queryset.update(obsolete=settings.OBSOLETE)
mark_as_obsolete.short_description = "Mark read length as obsolete"

def mark_as_non_obsolete(self,request,queryset):
queryset.update(obsolete=settings.NON_OBSOLETE)
mark_as_non_obsolete.short_description = "Mark read length as non-obsolete"

def obsolete_name(self,obj):

return "Non-obsolete" if obj.obsolete==settings.NON_OBSOLETE else "Obsolete"
obsolete_name.short_description = "STATUS"


class IndexI7Inline(admin.TabularInline):
Expand Down
1 change: 1 addition & 0 deletions library_sample_shared/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __str__(self):

class ReadLength(models.Model):
name = models.CharField('Name', max_length=50)
obsolete = models.PositiveIntegerField("Obsolete", default=1)

class Meta:
verbose_name = 'Read Length'
Expand Down
4 changes: 2 additions & 2 deletions library_sample_shared/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Meta:
class ReadLengthSerializer(ModelSerializer):
class Meta:
model = ReadLength
fields = ('id', 'name')
fields = ('id', 'name','obsolete')


class ConcentrationMethodSerializer(ModelSerializer):
Expand All @@ -41,7 +41,7 @@ class IndexTypeSerializer(ModelSerializer):
class Meta:
model = IndexType
fields = ('id', 'name', 'index_reads', 'is_dual', 'format',
'index_length',)
'index_length','obsolete')

def get_index_reads(self, obj):
return 2 if obj.is_dual else 1
Expand Down
3 changes: 2 additions & 1 deletion library_sample_shared/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class OrganismViewSet(MoveOtherMixin, viewsets.ReadOnlyModelViewSet):

class ReadLengthViewSet(viewsets.ReadOnlyModelViewSet):
""" Get the list of read lengths. """
queryset = ReadLength.objects.all()
#queryset = ReadLength.objects.all()
queryset = ReadLength.objects.filter(obsolete=settings.NON_OBSOLETE)
serializer_class = ReadLengthSerializer


Expand Down
4 changes: 4 additions & 0 deletions static/main-hub/app/model/libraries/IndexType.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Ext.define('MainHub.model.libraries.IndexType', {
{
name: 'format',
type: 'string'
},
{
name: 'obsolete',
type: 'int'
}
]
});
9 changes: 9 additions & 0 deletions static/main-hub/app/model/libraries/ReadLength.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Ext.define('MainHub.model.libraries.ReadLength', {
extend: 'MainHub.model.Base',

fields: [
{name: 'name', type: 'string'},
{name: 'id', type: 'int'},
{name: 'obsolete',type:'int'}
]
});
4 changes: 2 additions & 2 deletions static/main-hub/app/store/libraries/ReadLengths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Ext.define('MainHub.store.libraries.ReadLengths', {
storeId: 'readLengthsStore',

requires: [
'MainHub.model.libraries.LibraryField'
'MainHub.model.libraries.ReadLength'
],

model: 'MainHub.model.libraries.LibraryField',
model: 'MainHub.model.libraries.ReadLength',

proxy: {
type: 'ajax',
Expand Down
23 changes: 21 additions & 2 deletions static/main-hub/app/view/indexgenerator/IndexGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,33 @@ Ext.define('MainHub.view.indexgenerator.IndexGenerator', {
matchFieldWidth: false,
forceSelection: true
},

//tpl: Ext.create('Ext.XTemplate',
// '<tpl for=".">',
// ' <tpl if="obsolete==2">',
// ' <div class="x-boundlist-item x-item-disabled"><em>{name}</em></div>',
// ' <tpl else>',
// ' <div class="x-boundlist-item x-item-disabled"><em>{name}</em></div>',
// ' </tpl>',
// '</tpl>'),
renderer: function (value) {
var store = Ext.getStore('readLengthsStore');
var store = Ext.getStore('readLengthsStore');
var record = store.findRecord(
'id', value, 0, false, true, true
);

return (record) ? record.get('name') : '';
}
},
//listeners:{
//beforeselect: function(combo, record, index) {
//if(record.get('obsolete') == 2 ){
// return false;
// }
// }
//}

},

{
text: 'Protocol',
tooltip: 'Library Preparation Protocol',
Expand Down
19 changes: 19 additions & 0 deletions static/main-hub/sass/src/view/indexgenerator/IndexGenerator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@
color: #f44336;
font-weight: bold;
}

.x-item-disabled {
&.x-boundlist-item {
color: #8c8c8c;
cursor: default;
}
&.x-boundlist-item-over {
background: inherit;
border-color: white;
}
}

* grayed out combobox item */

.obsolete2 {
color: lightgray;
background-color: whitesmoke;
font-style: italic;
}

0 comments on commit b319a93

Please sign in to comment.