Ejemplo n.º 1
0
def execute():
    from webnotes.country_info import get_all
    data = get_all()

    webnotes.reload_doc("setup", "doctype", "country")
    webnotes.reload_doc("setup", "doctype", "currency")

    for c in webnotes.conn.sql("""select name from tabCountry"""):
        if c[0] in data:
            info = webnotes._dict(data[c[0]])
            doc = webnotes.doc("Country", c[0])
            doc.date_format = info.date_format or "dd-mm-yyyy"
            doc.time_zones = "\n".join(info.timezones or [])
            doc.save()

            if webnotes.conn.exists("Currency", info.currency):
                doc = webnotes.doc("Currency", info.currency)
                doc.fields.update({
                    "fraction":
                    info.currency_fraction,
                    "symbol":
                    info.currency_symbol,
                    "fraction_units":
                    info.currency_fraction_units
                })
                doc.save()
Ejemplo n.º 2
0
def save_perms_if_none_exist(doclist):
    if not webnotes.conn.sql(
            """select count(*) from tabDocPerm 
		where parent=%s""", doclist[0].name)[0][0]:
        for d in doclist:
            if d.get('doctype') != 'DocPerm': continue
            webnotes.doc(fielddata=d).save(1, check_links=0, ignore_fields=1)
Ejemplo n.º 3
0
def update_patch_log(patchmodule):
    """update patch_file in patch log"""
    if webnotes.conn.table_exists("__PatchLog"):
        webnotes.conn.sql("""INSERT INTO `__PatchLog` VALUES (%s, now())""", \
         patchmodule)
    else:
        webnotes.doc({"doctype": "Patch Log", "patch": patchmodule}).insert()
Ejemplo n.º 4
0
def update_patch_log(patchmodule):
	"""update patch_file in patch log"""	
	if webnotes.conn.table_exists("__PatchLog"):
		webnotes.conn.sql("""INSERT INTO `__PatchLog` VALUES (%s, now())""", \
			patchmodule)
	else:
		webnotes.doc({"doctype": "Patch Log", "patch": patchmodule}).insert()
Ejemplo n.º 5
0
def import_country_and_currency():
    from webnotes.country_info import get_all

    data = get_all()

    for name in data:
        country = webnotes._dict(data[name])
        webnotes.doc(
            {
                "doctype": "Country",
                "country_name": name,
                "date_format": country.date_format or "dd-mm-yyyy",
                "time_zones": "\n".join(country.timezones or []),
            }
        ).insert()

        if country.currency and not webnotes.conn.exists("Currency", country.currency):
            webnotes.doc(
                {
                    "doctype": "Currency",
                    "currency_name": country.currency,
                    "fraction": country.currency_fraction,
                    "symbol": country.currency_symbol,
                    "fraction_units": country.currency_fraction_units,
                    "number_format": country.number_format,
                }
            ).insert()
Ejemplo n.º 6
0
def build_sitemap_options(page_name):
	sitemap_options = webnotes.doc("Website Sitemap", page_name).fields
	
	# only non default fields
	for fieldname in default_fields:
		if fieldname in sitemap_options:
			del sitemap_options[fieldname]
	
	sitemap_config = webnotes.doc("Website Sitemap Config", 
		sitemap_options.get("website_sitemap_config")).fields
	
	# get sitemap config fields too
	for fieldname in ("base_template_path", "template_path", "controller", "no_cache", "no_sitemap", 
		"page_name_field", "condition_field"):
		sitemap_options[fieldname] = sitemap_config.get(fieldname)
	
	# establish hierarchy
	sitemap_options.parents = webnotes.conn.sql("""select name, page_title from `tabWebsite Sitemap`
		where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True)

	sitemap_options.children = webnotes.conn.sql("""select * from `tabWebsite Sitemap`
		where parent_website_sitemap=%s""", (sitemap_options.page_name,), as_dict=True)
	
	# determine templates to be used
	if not sitemap_options.base_template_path:
		sitemap_options.base_template_path = "templates/base.html"
		
	return sitemap_options
Ejemplo n.º 7
0
def get_lead_or_customer():
    customer = webnotes.conn.get_value("Contact",
                                       {"email_id": webnotes.session.user},
                                       "customer")
    if customer:
        return webnotes.doc("Customer", customer)

    lead = webnotes.conn.get_value("Lead", {"email_id": webnotes.session.user})
    if lead:
        return webnotes.doc("Lead", lead)
    else:
        lead_bean = webnotes.bean({
            "doctype":
            "Lead",
            "email_id":
            webnotes.session.user,
            "lead_name":
            get_fullname(webnotes.session.user),
            "territory":
            guess_territory(),
            "status":
            "Open"  # TODO: set something better???
        })

        if webnotes.session.user != "Guest":
            lead_bean.ignore_permissions = True
            lead_bean.insert()

        return lead_bean.doc
Ejemplo n.º 8
0
def execute():
    webnotes.reload_doc("core", "doctype", "patch_log")
    if webnotes.conn.table_exists("__PatchLog"):
        for d in webnotes.conn.sql("""select patch from __PatchLog"""):
            webnotes.doc({"doctype": "Patch Log", "patch": d[0]}).insert()

        webnotes.conn.commit()
        webnotes.conn.sql("drop table __PatchLog")
Ejemplo n.º 9
0
def save_perms_if_none_exist(doclist):
    if not webnotes.conn.sql(
        """select count(*) from tabDocPerm 
		where parent=%s""",
        doclist[0].name,
    )[0][0]:
        for d in doclist:
            if d.get("doctype") != "DocPerm":
                continue
            webnotes.doc(fielddata=d).save(1, check_links=0, ignore_fields=1)
Ejemplo n.º 10
0
def build_page(page_name):
    if not webnotes.conn:
        webnotes.connect()

    sitemap_options = webnotes.doc("Website Sitemap", page_name).fields

    page_options = webnotes.doc(
        "Website Sitemap Config",
        sitemap_options.get("website_sitemap_config")).fields.update({
            "page_name":
            sitemap_options.page_name,
            "docname":
            sitemap_options.docname
        })

    if not page_options:
        raise PageNotFoundError
    else:
        page_options["page_name"] = page_name

    basepath = webnotes.utils.get_base_path()
    no_cache = page_options.get("no_cache")

    # if generator, then load bean, pass arguments
    if page_options.get("page_or_generator") == "Generator":
        doctype = page_options.get("ref_doctype")
        obj = webnotes.get_obj(doctype,
                               page_options["docname"],
                               with_children=True)

        if hasattr(obj, 'get_context'):
            obj.get_context()

        context = webnotes._dict(obj.doc.fields)
        context["obj"] = obj
    else:
        # page
        context = webnotes._dict({'name': page_name})
        if page_options.get("controller"):
            module = webnotes.get_module(page_options.get("controller"))
            if module and hasattr(module, "get_context"):
                context.update(module.get_context())

    context.update(get_website_settings())

    jenv = webnotes.get_jenv()
    context["base_template"] = jenv.get_template(
        webnotes.get_config().get("base_template"))

    template_name = page_options['template_path']
    html = jenv.get_template(template_name).render(context)

    if not no_cache:
        webnotes.cache().set_value("page:" + page_name, html)
    return html
Ejemplo n.º 11
0
def execute():
	webnotes.reload_doc("core", "doctype", "patch_log")
	if webnotes.conn.table_exists("__PatchLog"):
		for d in webnotes.conn.sql("""select patch from __PatchLog"""):
			webnotes.doc({
				"doctype": "Patch Log",
				"patch": d[0]
			}).insert()
	
		webnotes.conn.commit()
		webnotes.conn.sql("drop table __PatchLog")
Ejemplo n.º 12
0
def add(parent, role, permlevel):
	webnotes.doc(fielddata={
		"doctype":"DocPerm",
		"__islocal": 1,
		"parent": parent,
		"parenttype": "DocType",
		"parentfield": "permissions",
		"role": role,
		"permlevel": permlevel,
		"read": 1
	}).save()
	
	validate_and_reset(parent)
Ejemplo n.º 13
0
def add(parent, role, permlevel):
	webnotes.only_for(("System Manager", "Administrator"))
	webnotes.doc(fielddata={
		"doctype":"DocPerm",
		"__islocal": 1,
		"parent": parent,
		"parenttype": "DocType",
		"parentfield": "permissions",
		"role": role,
		"permlevel": permlevel,
		"read": 1
	}).save()
	
	validate_and_reset(parent)
Ejemplo n.º 14
0
def build_page(page_name):
	if not webnotes.conn:
		webnotes.connect()

	sitemap_options = webnotes.doc("Website Sitemap", page_name).fields
	
	page_options = webnotes.doc("Website Sitemap Config", 
		sitemap_options.get("website_sitemap_config")).fields.update({
			"page_name":sitemap_options.page_name,
			"docname":sitemap_options.docname
		})
		
	if not page_options:
		raise PageNotFoundError
	else:
		page_options["page_name"] = page_name
	
	basepath = webnotes.utils.get_base_path()
	no_cache = page_options.get("no_cache")
	

	# if generator, then load bean, pass arguments
	if page_options.get("page_or_generator")=="Generator":
		doctype = page_options.get("ref_doctype")
		obj = webnotes.get_obj(doctype, page_options["docname"], with_children=True)

		if hasattr(obj, 'get_context'):
			obj.get_context()

		context = webnotes._dict(obj.doc.fields)
		context["obj"] = obj
	else:
		# page
		context = webnotes._dict({ 'name': page_name })
		if page_options.get("controller"):
			module = webnotes.get_module(page_options.get("controller"))
			if module and hasattr(module, "get_context"):
				context.update(module.get_context())
	
	context.update(get_website_settings())

	jenv = webnotes.get_jenv()
	context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template"))
	
	template_name = page_options['template_path']	
	html = jenv.get_template(template_name).render(context)
	
	if not no_cache:
		webnotes.cache().set_value("page:" + page_name, html)
	return html
Ejemplo n.º 15
0
def add(parent, role, permlevel):
    webnotes.only_for(("System Manager", "Administrator"))
    webnotes.doc(
        fielddata={
            "doctype": "DocPerm",
            "__islocal": 1,
            "parent": parent,
            "parenttype": "DocType",
            "parentfield": "permissions",
            "role": role,
            "permlevel": permlevel,
            "read": 1
        }).save()

    validate_and_reset(parent)
Ejemplo n.º 16
0
def make_lead(d, real_name, email_id):
	lead = webnotes.doc("Lead")
	lead.lead_name = real_name or email_id
	lead.email_id = email_id
	lead.source = "Email"
	lead.save(1)
	return lead.name
Ejemplo n.º 17
0
def make_lead(d, real_name):
	lead = webnotes.doc("Lead")
	lead.lead_name = real_name or d.sender
	lead.email_id = d.sender
	lead.source = "Email"
	lead.save(1)
	return lead.name
Ejemplo n.º 18
0
def get_pages(m):
	import importlib
	pages = webnotes.conn.sql_list("""select name from tabPage where module=%s""", m)
	prefix = "docs.dev.modules." + m + ".page."
	docs = {
		"_icon": "file-alt",
		"_label": "Pages",
		"_toc": [prefix + d for d in pages]
	}
	for p in pages:
		page = webnotes.doc("Page", p)
		mydocs = docs[p] = {
			"_label": page.title or p,
			"_type": "page",
		}
		update_readme(mydocs, m, "page", p)
		mydocs["_modified"] = page.modified

		# controller
		page_name = scrub(p)
		try:
			page_controller = importlib.import_module(scrub(m) + ".page." +  page_name + "." + page_name)
			inspect_object_and_update_docs(mydocs, page_controller)
		except ImportError, e:
			pass
Ejemplo n.º 19
0
def has_permission(doctype, ptype="read", refdoc=None, verbose=True):
	"""check if user has permission"""
	if webnotes.conn.get_value("DocType", doctype, "istable")==1:
		return True
	
	meta = webnotes.get_doctype(doctype)
	
	if ptype=="submit" and not cint(meta[0].is_submittable):
		return False
	
	if ptype=="import" and not cint(meta[0].allow_import):
		return False
	
	if webnotes.session.user=="Administrator":
		return True
		
	# get user permissions
	if not get_user_perms(meta).get(ptype):
		return False
		
	if refdoc:
		if isinstance(refdoc, basestring):
			refdoc = webnotes.doc(meta[0].name, refdoc)
		
		if not has_unrestricted_access(meta, refdoc, verbose=verbose):
			return False
		
		if not has_additional_permission(refdoc):
			return False

	return True
Ejemplo n.º 20
0
def execute():
    webnotes.reload_doc("setup", "doctype", "for_territory")
    webnotes.reload_doc("setup", "doctype", "price_list")
    webnotes.reload_doc("accounts", "doctype",
                        "sales_taxes_and_charges_master")
    webnotes.reload_doc("accounts", "doctype", "shipping_rule")

    from setup.utils import get_root_of
    root_territory = get_root_of("Territory")

    for parenttype in [
            "Sales Taxes and Charges Master", "Price List", "Shipping Rule"
    ]:
        for name in webnotes.conn.sql_list("""select name from `tab%s` main
			where not exists (select parent from `tabFor Territory` territory
				where territory.parenttype=%s and territory.parent=main.name)""" % \
          (parenttype, "%s"), (parenttype,)):

            doc = webnotes.doc({
                "doctype": "For Territory",
                "__islocal": 1,
                "parenttype": parenttype,
                "parentfield": "valid_for_territories",
                "parent": name,
                "territory": root_territory
            })
            doc.save()
Ejemplo n.º 21
0
def set_defaults(args):
	# enable default currency
	webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1)
	
	global_defaults = webnotes.bean("Global Defaults", "Global Defaults")
	global_defaults.doc.fields.update({
		'current_fiscal_year': args.curr_fiscal_year,
		'default_currency': args.get('currency'),
		'default_company':args.get('company_name'),
		'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"),
		"float_precision": 3,
		"is_active":1,
		"max_users":5,
		"country": args.get("country"),
		"time_zone": args.get("time_zone")
	})
	global_defaults.save()
	
	accounts_settings = webnotes.bean("Accounts Settings")
	accounts_settings.doc.auto_accounting_for_stock = 1
	accounts_settings.save()

	stock_settings = webnotes.bean("Stock Settings")
	stock_settings.doc.item_naming_by = "Item Code"
	stock_settings.doc.valuation_method = "FIFO"
	stock_settings.doc.stock_uom = "Nos"
	stock_settings.doc.auto_indent = 1
	stock_settings.save()
	
	selling_settings = webnotes.bean("Selling Settings")
	selling_settings.doc.cust_master_name = "Customer Name"
	selling_settings.doc.so_required = "No"
	selling_settings.doc.dn_required = "No"
	selling_settings.save()

	buying_settings = webnotes.bean("Buying Settings")
	buying_settings.doc.supp_master_name = "Supplier Name"
	buying_settings.doc.po_required = "No"
	buying_settings.doc.pr_required = "No"
	buying_settings.doc.maintain_same_rate = 1
	buying_settings.save()

	notification_control = webnotes.bean("Notification Control")
	notification_control.doc.quotation = 1
	notification_control.doc.sales_invoice = 1
	notification_control.doc.purchase_order = 1
	notification_control.save()

	hr_settings = webnotes.bean("HR Settings")
	hr_settings.doc.emp_created_by = "Naming Series"
	hr_settings.save()

	email_settings = webnotes.bean("Email Settings")
	email_settings.doc.send_print_in_body_and_attachment = 1
	email_settings.save()

	# control panel
	cp = webnotes.doc("Control Panel", "Control Panel")
	cp.company_name = args["company_name"]
	cp.save()
Ejemplo n.º 22
0
def boot_session(bootinfo):
	"""boot session - send website info if guest"""
	import webnotes
	import webnotes.model.doc
	
	bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
	bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')

	if webnotes.session['user']!='Guest':
		bootinfo['letter_heads'] = get_letter_heads()
		
		load_country_and_currency(bootinfo)
		
		import webnotes.model.doctype
		bootinfo['notification_settings'] = webnotes.doc("Notification Control", 
			"Notification Control").get_values()
				
		# if no company, show a dialog box to create a new company
		bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]

		if not bootinfo["customer_count"]:
			bootinfo['setup_complete'] = webnotes.conn.sql("""select name from 
				tabCompany limit 1""") and 'Yes' or 'No'
		
		
		# load subscription info
		from webnotes import conf
		for key in ['max_users', 'expires_on', 'max_space', 'status', 'commercial_support']:
			if key in conf: bootinfo[key] = conf.get(key)

		bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
            from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Ejemplo n.º 23
0
	def import_core_docs(self):
		install_docs = [
			{'doctype':'Module Def', 'name': 'Core', 'module_name':'Core'},

			# roles
			{'doctype':'Role', 'role_name': 'Administrator', 'name': 'Administrator'},
			{'doctype':'Role', 'role_name': 'All', 'name': 'All'},
			{'doctype':'Role', 'role_name': 'System Manager', 'name': 'System Manager'},
			{'doctype':'Role', 'role_name': 'Report Manager', 'name': 'Report Manager'},
			{'doctype':'Role', 'role_name': 'Guest', 'name': 'Guest'},

			# profiles
			{'doctype':'Profile', 'name':'Administrator', 'first_name':'Administrator', 
				'email':'admin@localhost', 'enabled':1},
			{'doctype':'Profile', 'name':'Guest', 'first_name':'Guest',
				'email':'guest@localhost', 'enabled':1},

			# userroles
			{'doctype':'UserRole', 'parent': 'Administrator', 'role': 'Administrator', 
				'parenttype':'Profile', 'parentfield':'user_roles'},
			{'doctype':'UserRole', 'parent': 'Guest', 'role': 'Guest', 
				'parenttype':'Profile', 'parentfield':'user_roles'}
		]
		
		webnotes.conn.begin()
		for d in install_docs:
			doc = webnotes.doc(fielddata=d)
			doc.insert()
		webnotes.conn.commit()
Ejemplo n.º 24
0
    def import_core_docs(self):
        install_docs = [
            # profiles
            {
                "doctype": "Profile",
                "name": "Administrator",
                "first_name": "Administrator",
                "email": "admin@localhost",
                "enabled": 1,
            },
            {"doctype": "Profile", "name": "Guest", "first_name": "Guest", "email": "guest@localhost", "enabled": 1},
            # userroles
            {
                "doctype": "UserRole",
                "parent": "Administrator",
                "role": "Administrator",
                "parenttype": "Profile",
                "parentfield": "user_roles",
            },
            {
                "doctype": "UserRole",
                "parent": "Guest",
                "role": "Guest",
                "parenttype": "Profile",
                "parentfield": "user_roles",
            },
            {"doctype": "Role", "role_name": "Report Manager"},
        ]

        webnotes.conn.begin()
        for d in install_docs:
            doc = webnotes.doc(fielddata=d)
            doc.insert()
        webnotes.conn.commit()
Ejemplo n.º 25
0
def load_country_and_currency(bootinfo):
	if bootinfo.control_panel.country and \
		webnotes.conn.exists("Country", bootinfo.control_panel.country):
		bootinfo["docs"] += [webnotes.doc("Country", bootinfo.control_panel.country)]
		
	bootinfo["docs"] += webnotes.conn.sql("""select * from tabCurrency
		where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
Ejemplo n.º 26
0
	def prepare_template_args(self):
		import webnotes.utils
		
		# this is for double precaution. usually it wont reach this code if not published
		if not webnotes.utils.cint(self.doc.published):
			raise Exception, "This blog has not been published yet!"
		
		# temp fields
		from webnotes.utils import global_date_format, get_fullname
		self.doc.full_name = get_fullname(self.doc.owner)
		self.doc.updated = global_date_format(self.doc.published_on)
		self.doc.content_html = self.doc.content
		if self.doc.blogger:
			self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
		
		self.doc.description = self.doc.blog_intro or self.doc.content[:140]
		
		self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
		
		self.doc.texts = {
			"comments": _("Comments"),
			"first_comment": _("Be the first one to comment"),
			"add_comment": _("Add Comment"),
			"submit": _("Submit"),
			"all_posts_by": _("All posts by"),
		}

		comment_list = webnotes.conn.sql("""\
			select comment, comment_by_fullname, creation
			from `tabComment` where comment_doctype="Blog Post"
			and comment_docname=%s order by creation""", self.doc.name, as_dict=1)
		
		self.doc.comment_list = comment_list or []
		for comment in self.doc.comment_list:
			comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
Ejemplo n.º 27
0
def make_lead(d, real_name):
    lead = webnotes.doc("Lead")
    lead.lead_name = real_name or d.sender
    lead.email_id = d.sender
    lead.source = "Email"
    lead.save(1)
    return lead.name
Ejemplo n.º 28
0
def get_pages(m):
    import importlib
    pages = webnotes.conn.sql_list(
        """select name from tabPage where module=%s""", m)
    prefix = "docs.dev.modules." + m + ".page."
    docs = {
        "_icon": "file-alt",
        "_label": "Pages",
        "_toc": [prefix + d for d in pages]
    }
    for p in pages:
        page = webnotes.doc("Page", p)
        mydocs = docs[p] = {
            "_label": page.title or p,
            "_type": "page",
        }
        update_readme(mydocs, m, "page", p)
        mydocs["_modified"] = page.modified

        # controller
        page_name = scrub(p)
        try:
            page_controller = importlib.import_module(
                scrub(m) + ".page." + page_name + "." + page_name)
            inspect_object_and_update_docs(mydocs, page_controller)
        except ImportError, e:
            pass
Ejemplo n.º 29
0
def import_doclist(doclist):
	doctype = doclist[0]["doctype"]
	name = doclist[0]["name"]
	old_doc = None
	
	doctypes = set([d["doctype"] for d in doclist])
	ignore = list(doctypes.intersection(set(ignore_doctypes)))
	
	if doctype in ignore_values:
		if webnotes.conn.exists(doctype, name):
			old_doc = webnotes.doc(doctype, name)

	# delete old
	webnotes.delete_doc(doctype, name, force=1, ignore_doctypes=ignore, for_reload=True)
	
	# don't overwrite ignored docs
	doclist1 = remove_ignored_docs_if_they_already_exist(doclist, ignore, name)

	# update old values (if not to be overwritten)
	if doctype in ignore_values and old_doc:
		update_original_values(doclist1, doctype, old_doc)
	
	# reload_new
	new_bean = webnotes.bean(doclist1)
	new_bean.ignore_children_type = ignore
	new_bean.ignore_links = True
	new_bean.ignore_validate = True
	new_bean.ignore_permissions = True
	new_bean.ignore_mandatory = True
	
	if doctype=="DocType" and name in ["DocField", "DocType"]:
		new_bean.ignore_fields = True
	
	new_bean.insert()
Ejemplo n.º 30
0
def boot_session(bootinfo):
	"""boot session - send website info if guest"""
	import webnotes
	import webnotes.model.doc
	
	bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
	bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')

	if webnotes.session['user']=='Guest':
		bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, 
			parent_label, parentfield
			from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1)
		bootinfo['startup_code'] = \
			webnotes.conn.get_value('Website Settings', None, 'startup_code')
	else:	
		bootinfo['letter_heads'] = get_letter_heads()

		import webnotes.model.doctype
		bootinfo['notification_settings'] = webnotes.doc("Notification Control", 
			"Notification Control").get_values()
		
		bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
		
		# if no company, show a dialog box to create a new company
		bootinfo['setup_complete'] = webnotes.conn.sql("""select name from 
			tabCompany limit 1""") and 'Yes' or 'No'
		
		# load subscription info
		import conf
		for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
			if hasattr(conf, key): bootinfo[key] = getattr(conf, key)

		bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", 
			as_dict=1, update={"doctype":":Company"})
Ejemplo n.º 31
0
	def validate_item(self, item_code, row_num):
		from stock.utils import validate_end_of_life, validate_is_stock_item, \
			validate_cancelled_item

		# using try except to catch all validation msgs and display together

		try:
			item = webnotes.doc("Item", item_code)
			if not item:
				raise webnotes.ValidationError, (_("Item: {0} not found in the system").format(item_code))

			# end of life and stock item
			validate_end_of_life(item_code, item.end_of_life, verbose=0)
			validate_is_stock_item(item_code, item.is_stock_item, verbose=0)

			# item should not be serialized
			if item.has_serial_no == "Yes":
				raise webnotes.ValidationError, (_("Serialized item: {0} can not be managed \
					using Stock Reconciliation, use Stock Entry instead").format(item_code))

			# item managed batch-wise not allowed
			if item.has_batch_no == "Yes":
				raise webnotes.ValidationError, (_("Item: {0} managed batch-wise, can not be \
					reconciled using Stock Reconciliation, instead use Stock Entry").format(item_code))

			# docstatus should be < 2
			validate_cancelled_item(item_code, item.docstatus, verbose=0)

		except Exception, e:
			self.validation_messages.append(_("Row # ") + ("%d: " % (row_num)) + cstr(e))
Ejemplo n.º 32
0
def add_all_roles_to(name):
	profile = webnotes.doc("Profile", name)
	for role in webnotes.conn.sql("""select name from tabRole"""):
		if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]:
			d = profile.addchild("user_roles", "UserRole")
			d.role = role[0]
			d.insert()
Ejemplo n.º 33
0
	def validate_item(self, item_code, row_num):
		from stock.utils import validate_end_of_life, validate_is_stock_item, \
			validate_cancelled_item
		
		# using try except to catch all validation msgs and display together
		
		try:
			item = webnotes.doc("Item", item_code)
			
			# end of life and stock item
			validate_end_of_life(item_code, item.end_of_life, verbose=0)
			validate_is_stock_item(item_code, item.is_stock_item, verbose=0)
		
			# item should not be serialized
			if item.has_serial_no == "Yes":
				raise webnotes.ValidationError, (_("Serialized Item: '") + item_code +
					_("""' can not be managed using Stock Reconciliation.\
					You can add/delete Serial No directly, \
					to modify stock of this item."""))
		
			# docstatus should be < 2
			validate_cancelled_item(item_code, item.docstatus, verbose=0)
				
		except Exception, e:
			self.validation_messages.append(_("Row # ") + ("%d: " % (row_num+2)) + cstr(e))
Ejemplo n.º 34
0
	def __init__(self, login=None, password=None, server=None, port=None, use_ssl=None):
		# get defaults from control panel
		try:
			es = webnotes.doc('Email Settings','Email Settings')
		except webnotes.DoesNotExistError:
			es = None
		
		self._sess = None
		if server:
			self.server = server
			self.port = port
			self.use_ssl = cint(use_ssl)
			self.login = login
			self.password = password
		elif es and es.outgoing_mail_server:
			self.server = es.outgoing_mail_server
			self.port = es.mail_port
			self.use_ssl = cint(es.use_ssl)
			self.login = es.mail_login
			self.password = es.mail_password
			self.always_use_login_id_as_sender = es.always_use_login_id_as_sender
		else:
			self.server = webnotes.conf.get("mail_server") or ""
			self.port = webnotes.conf.get("mail_port") or None
			self.use_ssl = cint(webnotes.conf.get("use_ssl") or 0)
			self.login = webnotes.conf.get("mail_login") or ""
			self.password = webnotes.conf.get("mail_password") or ""
def execute():
    webnotes.reload_doc("core", "doctype", "communication")
    webnotes.conn.commit()
    for d in webnotes.conn.sql(
            """select owner, creation, modified, modified_by, parent, 
		from_email, mail from `tabSupport Ticket Response`""",
            as_dict=1):
        c = webnotes.doc("Communication")
        c.creation = d.creation
        c.owner = d.owner
        c.modified = d.modified
        c.modified_by = d.modified_by
        c.naming_series = "COMM-"
        c.subject = "response to Support Ticket: " + d.parent
        c.content = d.mail
        c.email_address = d.from_email
        c.support_ticket = d.parent
        email_addr = email.utils.parseaddr(c.email_address)[1]
        c.contact = webnotes.conn.get_value(
            "Contact", {"email_id": email_addr}, "name") or None
        c.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr},
                                         "name") or None
        c.communication_medium = "Email"
        webnotes.conn.begin()
        c.save(1, keep_timestamps=True)
        webnotes.conn.commit()

    webnotes.delete_doc("DocType", "Support Ticket Response")
Ejemplo n.º 36
0
def boot_session(bootinfo):
	"""boot session - send website info if guest"""
	import webnotes
	import webnotes.model.doc
	
	bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
	bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')

	if webnotes.session['user']!='Guest':
		bootinfo['letter_heads'] = get_letter_heads()
		
		load_country_and_currency(bootinfo)
		
		import webnotes.model.doctype
		bootinfo['notification_settings'] = webnotes.doc("Notification Control", 
			"Notification Control").get_values()
				
		# if no company, show a dialog box to create a new company
		bootinfo["customer_count"] = webnotes.conn.sql("""select count(*) from tabCustomer""")[0][0]

		if not bootinfo["customer_count"]:
			bootinfo['setup_complete'] = webnotes.conn.sql("""select name from 
				tabCompany limit 1""") and 'Yes' or 'No'
		
		
		# load subscription info
		import conf
		for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
			if hasattr(conf, key): bootinfo[key] = getattr(conf, key)

		bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
            from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Ejemplo n.º 37
0
def make(doctype=None, name=None, content=None, subject=None, 
	sender=None, recipients=None, contact=None, lead=None, company=None, 
	communication_medium="Email", send_email=False, print_html=None,
	attachments='[]', send_me_a_copy=False, set_lead=True, date=None):
	# add to Communication
	sent_via = None
	
	d = webnotes.doc('Communication')
	d.subject = subject
	d.content = content
	d.sender = sender or webnotes.conn.get_value("Profile", webnotes.session.user, "email")
	d.recipients = recipients
	d.lead = lead
	d.contact = contact
	d.company = company
	if date:
		d.creation = date
	if doctype:
		sent_via = webnotes.get_obj(doctype, name)
		d.fields[doctype.replace(" ", "_").lower()] = name

	if set_lead:
		set_lead_and_contact(d)
	d.communication_medium = communication_medium
	if send_email:
		send_comm_email(d, name, sent_via, print_html, attachments, send_me_a_copy)
	d.save(1, ignore_fields=True)
Ejemplo n.º 38
0
def get_parent_item_groups(item_group_name):
    item_group = webnotes.doc("Item Group", item_group_name)
    return webnotes.conn.sql("""select name, page_name from `tabItem Group`
		where lft <= %s and rgt >= %s 
		and ifnull(show_in_website,0)=1
		order by lft asc""", (item_group.lft, item_group.rgt),
                             as_dict=True)
Ejemplo n.º 39
0
def run(report_name, filters=None):
	report = webnotes.doc("Report", report_name)
	
	if filters and isinstance(filters, basestring):
		filters = json.loads(filters)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query, filters)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)(filters or {})
	
	result = get_filtered_data(report.ref_doctype, columns, result)
	
	if cint(report.add_total_row) and result:
		result = add_total_row(result, columns)
	
	return {
		"result": result,
		"columns": columns
	}
Ejemplo n.º 40
0
    def validate_item(self, item_code, row_num):
        from stock.utils import validate_end_of_life, validate_is_stock_item, \
         validate_cancelled_item

        # using try except to catch all validation msgs and display together

        try:
            item = webnotes.doc("Item", item_code)
            if not item:
                raise webnotes.ValidationError, (
                    _("Item: {0} not found in the system").format(item_code))

            # end of life and stock item
            validate_end_of_life(item_code, item.end_of_life, verbose=0)
            validate_is_stock_item(item_code, item.is_stock_item, verbose=0)

            # item should not be serialized
            if item.has_serial_no == "Yes":
                raise webnotes.ValidationError, (
                    _("Serialized item: {0} can not be managed \
					using Stock Reconciliation, use Stock Entry instead").format(item_code))

            # item managed batch-wise not allowed
            if item.has_batch_no == "Yes":
                raise webnotes.ValidationError, (
                    _("Item: {0} managed batch-wise, can not be \
					reconciled using Stock Reconciliation, instead use Stock Entry").format(
                        item_code))

            # docstatus should be < 2
            validate_cancelled_item(item_code, item.docstatus, verbose=0)

        except Exception, e:
            self.validation_messages.append(
                _("Row # ") + ("%d: " % (row_num)) + cstr(e))
Ejemplo n.º 41
0
def run(report_name):
	report = webnotes.doc("Report", report_name)

	if not webnotes.has_permission(report.ref_doctype, "report"):
		webnotes.msgprint(_("Must have report permission to access this report."), 
			raise_exception=True)
	
	if report.report_type=="Query Report":
		if not report.query:
			webnotes.msgprint(_("Must specify a Query to run"), raise_exception=True)
	
	
		if not report.query.lower().startswith("select"):
			webnotes.msgprint(_("Query must be a SELECT"), raise_exception=True)
		
		result = [list(t) for t in webnotes.conn.sql(report.query)]
		columns = [c[0] for c in webnotes.conn.get_description()]
	else:
		from webnotes.modules import scrub
		method_name = scrub(webnotes.conn.get_value("DocType", report.ref_doctype, "module")) \
			+ ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
		columns, result = webnotes.get_method(method_name)()
	
	return {
		"result": result,
		"columns": columns
	}
Ejemplo n.º 42
0
def load_country_and_currency(bootinfo, doclist):
	if bootinfo.control_panel.country and \
		webnotes.conn.exists("Country", bootinfo.control_panel.country):
		doclist += [webnotes.doc("Country", bootinfo.control_panel.country)]
		
	doclist += webnotes.conn.sql("""select * from tabCurrency
		where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
Ejemplo n.º 43
0
    def get_context(self):
        import webnotes.utils
        import markdown2

        # this is for double precaution. usually it wont reach this code if not published
        if not webnotes.utils.cint(self.doc.published):
            raise Exception, "This blog has not been published yet!"

        # temp fields
        from webnotes.utils import global_date_format, get_fullname
        self.doc.full_name = get_fullname(self.doc.owner)
        self.doc.updated = global_date_format(self.doc.published_on)

        if self.doc.blogger:
            self.doc.blogger_info = webnotes.doc("Blogger",
                                                 self.doc.blogger).fields

        self.doc.description = self.doc.blog_intro or self.doc.content[:140]
        self.doc.meta_description = self.doc.description

        self.doc.categories = webnotes.conn.sql_list(
            "select name from `tabBlog Category` order by name")

        self.doc.comment_list = webnotes.conn.sql("""\
			select comment, comment_by_fullname, creation
			from `tabComment` where comment_doctype="Blog Post"
			and comment_docname=%s order by creation""",
                                                  self.doc.name,
                                                  as_dict=1) or []
Ejemplo n.º 44
0
	def get_context(self):
		import webnotes.utils
		import markdown2
		
		# this is for double precaution. usually it wont reach this code if not published
		if not webnotes.utils.cint(self.doc.published):
			raise Exception, "This blog has not been published yet!"
		
		# temp fields
		from webnotes.utils import global_date_format, get_fullname
		self.doc.full_name = get_fullname(self.doc.owner)
		self.doc.updated = global_date_format(self.doc.published_on)
		
		if self.doc.blogger:
			self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields
		
		self.doc.description = self.doc.blog_intro or self.doc.content[:140]
		self.doc.meta_description = self.doc.description
		
		self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name")
		
		self.doc.comment_list = webnotes.conn.sql("""\
			select comment, comment_by_fullname, creation
			from `tabComment` where comment_doctype="Blog Post"
			and comment_docname=%s order by creation""", self.doc.name, as_dict=1) or []
Ejemplo n.º 45
0
def add_all_roles_to(name):
	profile = webnotes.doc("Profile", name)
	for role in webnotes.conn.sql("""select name from tabRole"""):
		if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]:
			d = profile.addchild("user_roles", "UserRole")
			d.role = role[0]
			d.insert()
Ejemplo n.º 46
0
def get_context():
	"""generate rss feed"""
		
	host = get_request_site_address()
	
	blog_list = webnotes.conn.sql("""\
		select page_name as name, published_on, modified, title, content from `tabBlog Post` 
		where ifnull(published,0)=1
		order by published_on desc limit 20""", as_dict=1)

	for blog in blog_list:
		blog.link = urllib.quote(host + '/' + blog.name + '.html')
		blog.content = escape_html(blog.content or "")
	
	if blog_list:
		modified = max((blog['modified'] for blog in blog_list))
	else:
		modified = now()

	ws = webnotes.doc('Website Settings', 'Website Settings')

	context = {
		'title': ws.title_prefix,
		'description': ws.description or ((ws.title_prefix or "") + ' Blog'),
		'modified': modified,
		'items': blog_list,
		'link': host + '/blog'
	}
	
	webnotes.response.content_type = "text/xml"
	
	# print context
	return context
	
Ejemplo n.º 47
0
	def validate_item(self, item_code, row_num):
		from stock.utils import validate_end_of_life, validate_is_stock_item, \
			validate_cancelled_item
		
		# using try except to catch all validation msgs and display together
		
		try:
			item = webnotes.doc("Item", item_code)
			
			# end of life and stock item
			validate_end_of_life(item_code, item.end_of_life, verbose=0)
			validate_is_stock_item(item_code, item.is_stock_item, verbose=0)
		
			# item should not be serialized
			if item.has_serial_no == "Yes":
				raise webnotes.ValidationError, (_("Serialized Item: '") + item_code +
					_("""' can not be managed using Stock Reconciliation.\
					You can add/delete Serial No directly, \
					to modify stock of this item."""))
		
			# docstatus should be < 2
			validate_cancelled_item(item_code, item.docstatus, verbose=0)
				
		except Exception, e:
			self.validation_messages.append(_("Row # ") + ("%d: " % (row_num+2)) + cstr(e))
Ejemplo n.º 48
0
def make_word_map():
    webnotes.conn.sql("""delete from tabWord""")
    webnotes.conn.sql("""delete from `tabWord Data Set`""")
    webnotes.conn.commit()
    webnotes.conn.auto_commit_on_many_writes = True
    for d in webnotes.conn.sql("""select name, ifnull(title, "") as title, 
		ifnull(description, "") as description 
		from `tabData Set`""",
                               as_dict=True):
        sys.stdout.write(".")
        sys.stdout.flush()

        # cleanup
        all_text = d.title + d.description
        all_text = all_text.replace("%", "percent").replace('"', "")
        for t in replace_with_space:
            all_text = all_text.replace(t, " ")
        for t in eliminate_list:
            all_text = all_text.replace(t, "")

        for word in all_text.split():
            name = word.title()
            if len(name) > 5 and (name not in common_list):
                if not webnotes.conn.exists("Word", name):
                    webnotes.doc({
                        "doctype": "Word",
                        "name": name,
                        "count": 1
                    }).insert()
                else:
                    webnotes.conn.sql(
                        """update tabWord set `count`=`count` + 1 where name=%s""",
                        name)

                if not webnotes.conn.sql(
                        """select name from `tabWord Data Set` 
					where word=%s and data_set=%s""", (name, d.name)):
                    webnotes.doc({
                        "doctype": "Word Data Set",
                        "data_set": d.name,
                        "word": name
                    }).insert()

    for d in webnotes.conn.sql("select name from tabWord where `count`< 100"):
        webnotes.delete_doc('Word', d[0])

    webnotes.conn.commit()
Ejemplo n.º 49
0
def get_website_settings():
	from webnotes.utils import get_request_site_address, encode, cint
	from urllib import quote
		
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
					
	context = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"webnotes": webnotes,
		"utils": webnotes.utils,
		"post_login": [
			{"label": "Reset Password", "url": "update-password", "icon": "icon-key"},
			{"label": "Logout", "url": "/?cmd=web_logout", "icon": "icon-signout"}
		]
	})
		
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			context[k] = settings.fields.get(k)
			
	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = cint(context.get(k) or 0)
	
	context.url = quote(str(get_request_site_address(full_address=True)), str(""))
	context.encoded_title = quote(encode(context.title or ""), str(""))
	
	try:
		import startup.webutils
		if hasattr(startup.webutils, "get_website_settings"):
			startup.webutils.get_website_settings(context)
	except:
		pass
	return context
Ejemplo n.º 50
0
def set_defaults(args):
    # enable default currency
    webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1)

    global_defaults = webnotes.bean("Global Defaults", "Global Defaults")
    global_defaults.doc.fields.update({
        'current_fiscal_year':
        args.curr_fiscal_year,
        'default_currency':
        args.get('currency'),
        'default_company':
        args.get('company_name'),
        'date_format':
        webnotes.conn.get_value("Country", args.get("country"), "date_format"),
        "float_precision":
        4
    })
    global_defaults.save()

    accounts_settings = webnotes.bean("Accounts Settings")
    accounts_settings.doc.auto_accounting_for_stock = 1
    accounts_settings.save()

    stock_settings = webnotes.bean("Stock Settings")
    stock_settings.doc.item_naming_by = "Item Code"
    stock_settings.doc.valuation_method = "FIFO"
    stock_settings.doc.stock_uom = "Nos"
    stock_settings.doc.auto_indent = 1
    stock_settings.save()

    selling_settings = webnotes.bean("Selling Settings")
    selling_settings.doc.cust_master_name = "Customer Name"
    selling_settings.doc.so_required = "No"
    selling_settings.doc.dn_required = "No"
    selling_settings.save()

    buying_settings = webnotes.bean("Buying Settings")
    buying_settings.doc.supp_master_name = "Supplier Name"
    buying_settings.doc.po_required = "No"
    buying_settings.doc.pr_required = "No"
    buying_settings.doc.maintain_same_rate = 1
    buying_settings.save()

    notification_control = webnotes.bean("Notification Control")
    notification_control.doc.quotation = 1
    notification_control.doc.sales_invoice = 1
    notification_control.doc.purchase_order = 1
    notification_control.save()

    hr_settings = webnotes.bean("HR Settings")
    hr_settings.doc.emp_created_by = "Naming Series"
    hr_settings.save()

    # control panel
    cp = webnotes.doc("Control Panel", "Control Panel")
    for k in ['country', 'timezone', 'company_name']:
        cp.fields[k] = args[k]

    cp.save()
Ejemplo n.º 51
0
def get_website_settings():
	from webnotes.utils import get_request_site_address, encode, cint
	from urllib import quote
		
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
					
	context = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"webnotes": webnotes,
		"utils": webnotes.utils,
		"post_login": [
			{"label": "Reset Password", "url": "update-password", "icon": "icon-key"},
			{"label": "Logout", "url": "/?cmd=web_logout", "icon": "icon-signout"}
		]
	})
		
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			context[k] = settings.fields.get(k)
			
	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = cint(context.get(k) or 0)
	
	context.url = quote(str(get_request_site_address(full_address=True)), str(""))
	context.encoded_title = quote(encode(context.title or ""), str(""))
	
	try:
		import startup.webutils
		if hasattr(startup.webutils, "get_website_settings"):
			startup.webutils.get_website_settings(context)
	except:
		pass
	return context
Ejemplo n.º 52
0
def get_blog_template_args():
    args = {
        "categories":
        webnotes.conn.sql_list(
            "select name from `tabBlog Category` order by name")
    }
    args.update(webnotes.doc("Blog Settings", "Blog Settings").fields)
    return args
Ejemplo n.º 53
0
 def validate(self):
     self.set_status()
     self.doc.total_hours = 0.0
     for d in self.doclist.get({"doctype": "Time Log Batch Detail"}):
         tl = webnotes.doc("Time Log", d.time_log)
         self.update_time_log_values(d, tl)
         self.validate_time_log_is_submitted(tl)
         self.doc.total_hours += float(tl.hours or 0.0)
Ejemplo n.º 54
0
def get_context():
    """returns web style"""
    from webnotes.webutils import get_hex_shade

    doc = webnotes.doc("Style Settings", "Style Settings")
    prepare(doc)

    return {"doc": doc, "get_hex_shade": get_hex_shade}
Ejemplo n.º 55
0
 def onload(self):
     """load employee"""
     emp_list = []
     for d in self.doclist.get({"doctype": "About Us Team Member"}):
         emp = webnotes.doc("Employee", d.employee)
         emp.image = url_for_website(emp.image)
         emp_list.append(emp)
     self.doclist += emp_list