code shifted from custom script to py file

This commit is contained in:
Nabin Hait 2011-08-29 14:31:35 +05:30
parent 6b9022140c
commit 567e4e5b64
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,9 @@
cur_frm.cscript.onload = function(doc, cdt, cdn) {
var df = get_field('Event', 'Intro HTML', doc.name);
if(doc.ref_type) {
ref = repl(cur_frm.cstring.ref_html, {'dt': doc.ref_type, 'dn':doc.ref_name});
} else var ref = '';
df.options = repl(cur_frm.cstring.intro_html, {'ref': ref});
refresh_fields('Intro HTML');
}

View file

@ -0,0 +1,14 @@
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d,dl
def validate(self):
# check for extension
if not '.' in self.doc.file_name:
msgprint("Extension required in file name")
raise Exception
# set mime type
if not self.doc.mime_type:
import mimetypes
self.doc.mime_type = mimetypes.guess_type(self.doc.file_name)[0] or 'application/unknown'