def set_user_image(fid, fname):
	"""
		Set uploaded image as user image
	"""
	from webnotes.utils.file_manager import add_file_list, remove_all
	remove_all('Profile', webnotes.session['user'])
	add_file_list('Profile', webnotes.session['user'], fname, fid)
Exemple #2
0
def set_user_background(fid, fname):
    """
		Set uploaded image as user image
	"""
    from webnotes.utils.file_manager import add_file_list, remove_file
    user = webnotes.session['user']

    # remove old file
    old_image = webnotes.conn.get_value('Profile', user, 'background_image')
    if old_image:
        remove_file('Profile', user, old_image)

    # add new file
    add_file_list('Profile', user, fname, fid)
    webnotes.conn.set_value('Profile', user, 'background_image', fid)
Exemple #3
0
def set_user_background(fid, fname):
    """
		Set uploaded image as user image
	"""
    from webnotes.utils.file_manager import add_file_list, remove_file

    user = webnotes.session["user"]

    # remove old file
    old_image = webnotes.conn.get_value("Profile", user, "background_image")
    if old_image:
        remove_file("Profile", user, old_image)

        # add new file
    add_file_list("Profile", user, fname, fid)
    webnotes.conn.set_value("Profile", user, "background_image", fid)
	def save_attachments_in_doc(self, doc):
		from webnotes.utils.file_manager import save_file, add_file_list, MaxFileSizeReachedError
		for attachment in self.attachments:
			try:
				fid = save_file(attachment['filename'], attachment['content'])
				status = add_file_list(doc.doctype, doc.name, fid, fid)
			except MaxFileSizeReachedError:
				# bypass max file size exception
				pass
Exemple #5
0
def set_user_background():
	"""
		Set uploaded image as user image
	"""
	check_demo()
	from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
	user = webnotes.session['user']

	fid, fname = save_uploaded()
	
	# remove old file
	old_image = webnotes.conn.get_value('Profile', user, 'background_image')
	if old_image:
		remove_file('Profile', user, old_image)
		
	# add new file
	add_file_list('Profile', user, fname, fid)
	webnotes.conn.set_value('Profile', user, 'background_image', fid)
	
	return fid
Exemple #6
0
def set_user_image():
	"""
		Set uploaded image as user image
	"""
	check_demo()
	from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
	user = webnotes.session['user']

	fid, fname = save_uploaded()
		
	# remove old file
	old_image = webnotes.conn.get_value('Profile', user, 'user_image')
	if old_image:
		remove_file('Profile', user, old_image)
		
	# add new file
	add_file_list('Profile', user, fname, fid)
	webnotes.conn.set_value('Profile', user, 'user_image', fid)
	
	return fid
Exemple #7
0
	def save_attachments(self, doc, attachment_list=[]):
		"""
			Saves attachments from email

			attachment_list is a list of dict containing:
			'filename', 'content', 'content-type'
		"""
		from webnotes.utils.file_manager import save_file, add_file_list
		for attachment in attachment_list:
			fid = save_file(attachment['filename'], attachment['content'], 'Support')
			status = add_file_list('Support Ticket', doc.name, attachment['filename'], fid)
			if not status:
				doc.description = doc.description \
					+ "\nCould not attach: " + cstr(attachment['filename'])
				doc.save()
Exemple #8
0
	def save_attachments(self, doc, attachment_list=[]):
		"""
			Saves attachments from email

			attachment_list is a list of dict containing:
			'filename', 'content', 'content-type'
		"""
		from webnotes.utils.file_manager import save_file, add_file_list
		for attachment in attachment_list:
			fid = save_file(attachment['filename'], attachment['content'], 'Support')
			status = add_file_list('Support Ticket', doc.name, attachment['filename'], fid)
			if not status:
				doc.description = doc.description \
					+ "\nCould not attach: " + cstr(attachment['filename'])
				doc.save()
Exemple #9
0
    def save_attachments(self, doc, attachment_list=[]):
        """
			Saves attachments from email

			attachment_list is a list of dict containing:
			'filename', 'content', 'content-type'
		"""
        from webnotes.utils.file_manager import save_file, add_file_list

        for attachment in attachment_list:
            webnotes.conn.begin()
            fid = save_file(attachment["filename"], attachment["content"], "Support")
            status = add_file_list("Support Ticket", doc.name, attachment["filename"], fid)
            if not status:
                doc.description = doc.description + "\nCould not attach: " + cstr(attachment["filename"])
                doc.save()
            webnotes.conn.commit()
Exemple #10
0
	def save_attachments_in_doc(self, doc):
		from webnotes.utils.file_manager import save_file, add_file_list
		for attachment in self.attachments:
			fid = save_file(attachment['filename'], attachment['content'])
			status = add_file_list(doc.doctype, doc.name, fid, fid)