code shifted from custom script to py file
This commit is contained in:
parent
6b9022140c
commit
567e4e5b64
2 changed files with 23 additions and 0 deletions
9
cgi-bin/core/doctype/event/event.js
Normal file
9
cgi-bin/core/doctype/event/event.js
Normal 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');
|
||||
}
|
||||
14
cgi-bin/core/doctype/file/file.py
Normal file
14
cgi-bin/core/doctype/file/file.py
Normal 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'
|
||||
Loading…
Add table
Reference in a new issue