Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rebekkjm committed Jul 25, 2011
2 parents 4c0bbe0 + 704835a commit 404ab69
Show file tree
Hide file tree
Showing 77 changed files with 2,681 additions and 736 deletions.
10 changes: 6 additions & 4 deletions devilry/apps/administrator/editorviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.http import HttpResponseNotFound

import restful
from views import add_restfulapi_to_context


class RestfulSimplifiedEditorView(View):
Expand All @@ -19,15 +20,16 @@ def get(self, request, record_id):
record_id = int(record_id)
else:
return HttpResponseNotFound()
templatevars = {'record_id': record_id,
context = {'record_id': record_id,
'initial_mode': initial_mode,
'RestfulSimplifiedClass': self.restful}
return render(request, self.template_name, templatevars)
add_restfulapi_to_context(context)
return render(request, self.template_name, context)

@classmethod
def create_url(cls):
prefix = cls.__name__.replace('Editor', '').lower()
return url(r'^editors/{0}/(?P<record_id>\w+)?'.format(prefix),
prefix = cls.__name__.replace('Editor', '').replace('RestfulSimplified', '').lower()
return url(r'^{0}/edit/(?P<record_id>\w+)?'.format(prefix),
login_required(cls.as_view()),
name='administrator-editors-{0}'.format(prefix))

Expand Down
2 changes: 1 addition & 1 deletion devilry/apps/administrator/restful.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SimplifiedDelivery, SimplifiedDeadline,
SimplifiedStaticFeedback, SimplifiedFileMeta)
from ..extjshelpers import extjs_restful_modelapi#, wizard
from ..student import restfulmetabases
from devilry.coreutils.restful import metabases as restfulmetabases


__all__ = ('RestfulSimplifiedNode', 'RestfulSimplifiedSubject',
Expand Down
17 changes: 10 additions & 7 deletions devilry/apps/administrator/simplified.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
from ...simplified import (SimplifiedModelApi, simplified_modelapi,
PermissionDenied, FieldSpec,
FilterSpecs, FilterSpec, ForeignFilterSpec, PatternFilterSpec)
FilterSpecs, FilterSpec, PatternFilterSpec)
from ..core import models

from ..student.simplifiedmetabases import (SimplifiedSubjectMetaMixin,
SimplifiedPeriodMetaMixin, SimplifiedAssignmentMetaMixin,
SimplifiedAssignmentGroupMetaMixin, SimplifiedDeadlineMetaMixin,
SimplifiedDeliveryMetaMixin, SimplifiedStaticFeedbackMetaMixin,
SimplifiedFileMetaMetaMixin)
from devilry.coreutils.simplified.metabases import (SimplifiedSubjectMetaMixin,
SimplifiedPeriodMetaMixin,
SimplifiedAssignmentMetaMixin,
SimplifiedAssignmentGroupMetaMixin,
SimplifiedDeadlineMetaMixin,
SimplifiedDeliveryMetaMixin,
SimplifiedStaticFeedbackMetaMixin,
SimplifiedFileMetaMetaMixin)

__all__ = ('SimplifiedNode', 'SimplifiedSubject', 'SimplifiedPeriod', 'SimplifiedAssignment')



class CanSaveBase(SimplifiedModelApi):
""" Mixin class extended by many of the classes in the Simplified API for Administrator """
@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/** SearchWidget used in every page in the entire administrator interface.
*
* Enables users to search for everything (like the dashboard) or just within
* the current item.
* */
Ext.define('devilry.administrator.AdministratorSearchWidget', {
extend: 'devilry.extjshelpers.searchwidget.SearchWidget',
requires: [
'devilry.extjshelpers.searchwidget.FilterConfigDefaults',
],

config: {
/**
* @cfg
* Url prefix. Should be the absolute URL path to /administrator/.
*/
urlPrefix: '',

/**
* @cfg
* ``Ext.XTemplate`` for Node rows.
*/
nodeRowTpl: '',

/**
* @cfg
* ``Ext.XTemplate`` for Subject rows.
*/
subjectRowTpl: '',

/**
* @cfg
* ``Ext.XTemplate`` for Period rows.
*/
periodRowTpl: '',

/**
* @cfg
* ``Ext.XTemplate`` for Assignment rows.
*/
assignmentRowTpl: '',

/**
* @cfg
* ``Ext.XTemplate`` for AssignmentGroup rows.
*/
assignmentgroupRowTpl: '',

/**
* @cfg
* ``Ext.XTemplate`` for Delivery rows.
*/
deliveryRowTpl: ''
},

initComponent: function() {
Ext.apply(this, {
searchResultItems: [{
xtype: 'searchresults',
title: 'Nodes',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedNodeStoreSearch'),
filterconfig: {
type: 'node'
},
resultitemConfig: {
tpl: this.nodeRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'node/view/{id}'
}
}
}, {
xtype: 'searchresults',
title: 'Subjects',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedSubjectStoreSearch'),
filterconfig: {
type: 'subject'
},
resultitemConfig: {
tpl: this.subjectRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'subject/view/{id}'
}
}
}, {
xtype: 'searchresults',
title: 'Periods',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedPeriodStoreSearch'),
filterconfig: {
type: 'period'
},
resultitemConfig: {
tpl: this.periodRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'period/view/{id}'
}
}
}, {
xtype: 'searchresults',
title: 'Assignments',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedAssignmentStoreSearch'),
filterconfig: devilry.extjshelpers.searchwidget.FilterConfigDefaults.assignment,
resultitemConfig: {
tpl: this.assignmentRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'assignment/view/{id}'
},
menuitems: [{
text: 'Show deliveries',
clickFilter: 'type:delivery assignment:{id}'
}]
}
}, {
xtype: 'searchresults',
title: 'Assignment groups',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedAssignmentGroupStoreSearch'),
filterconfig: devilry.extjshelpers.searchwidget.FilterConfigDefaults.assignmentgroup,
resultitemConfig: {
tpl: this.assignmentgroupRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'assignmentgroup/view/{id}'
}
}
}, {
xtype: 'searchresults',
title: 'Delivery',
store: Ext.data.StoreManager.lookup('devilry.apps.administrator.simplified.SimplifiedDeliveryStoreSearch'),
filterconfig: devilry.extjshelpers.searchwidget.FilterConfigDefaults.delivery,
resultitemConfig: {
tpl: this.deliveryRowTpl,
defaultbutton: {
text: 'View',
clickLinkTpl: this.urlPrefix + 'assignmentgroup/view/{deadline__assignment_group}?deliveryid={id}'
}
}
}]
});
this.callParent(arguments);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** Default config for the Create New window, which is opened to create an item
* in the admin interface. */
Ext.define('devilry.administrator.DefaultCreateWindow', {
extend: 'devilry.administrator.DefaultEditWindow',
title: 'Create new',

config: {
/**
* @cfg
* ``Ext.XTemplate`` for the url to visit on successful save. The
* template gets the record data as input.
*/
successUrlTpl: undefined
},

onSaveSuccess: function(record) {
window.location.href = this.successUrlTpl.apply(record.data);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** Default config for the Edit window, which is opened to edit an item in the
* admin interface. */
Ext.define('devilry.administrator.DefaultEditWindow', {
extend: 'devilry.administrator.DefaultEditWindowBase',
title: 'Edit',

config: {
/**
* @cfg
* The {@link devilry.administrator.PrettyView} to refresh when a save succeeds.
*/
prettyview: undefined
},

onSaveSuccess: function(record) {
this.prettyview.setRecord(record);
this.close();
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/** Base class for the default config for the Edit/Create new window, which is
* opened to edit/create new item in the admin interface. */
Ext.define('devilry.administrator.DefaultEditWindowBase', {
extend: 'Ext.window.Window',
width: 800,
height: 600,
layout: 'fit',
maximizable: true,

config: {
/**
* @cfg
* The {@link devilry.administrator.EditPanel} to use for editing.
*/
editpanel: undefined
},

constructor: function(config) {
this.callParent([config]);
this.initConfig(config);
},

initComponent: function() {
var me = this;
this.editpanel.addListener('saveSucess', function(record) {
me.onSaveSuccess(record);
});

Ext.apply(this, {
items: this.editpanel
});
this.callParent(arguments);
},

onSaveSuccess: function(record) {
throw "Must implement onSaveSuccess()"
}
});
Loading

0 comments on commit 404ab69

Please sign in to comment.