I maid picture upload function as shopping management.
web:
http://www.henojiya.net/shopping/
source:
https://github.com/duri0214/Portfolio/tree/master/mysite/shopping
Now, I problem this.
permission error.
log:
https://github.com/duri0214/Portfolio/issues/25
I was look at log message.
FILE_UPLOAD_DIRECTORY_PERMISSIONS
None
FILE_UPLOAD_PERMISSIONS
420
420???
I think django default permission is 644.
official document:
https://docs.djangoproject.com/en/3.0/ref/settings/#file-upload-permissions
local upload test is ok!
I want picture upload.
thank you
add info
drwxr-xr-x. op op mysite
└drwxrwxr-x. op op shopping
└drwxrwxr-x. op op static
└drwxrwxr-x. op op shopping
└drwxrwxr-x. op op img
OK! I fixed it.
I didn't know the role of "media" in "setting.py".
django want to save to '[example.com]/media' if add write to 'setting.py'
I am no edit apache file.
# setting.py
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
In 'models.py', if upload_to ='shopping/' is set, it will be saved as [example.com] /media/shopping/xxx.jpg
# models.py
class Products(models.Model):
"""product"""
code = models.CharField('code', max_length=200)
name = models.CharField('product_name', max_length=200)
price = models.IntegerField('product_price', default=0)
description = models.TextField('description')
picture = models.ImageField('picture', upload_to='shopping/')
Related
So i want to mass follow people on Twitter with my account
but im kinda confused because i don't know how to fix the error, like i've requested to follow the "user", so what i want to do is skip the user if ive requested to follow them, but i dont know how to fix it, here's the code
`
following = api.get_friend_ids(screen_name = "2Wild2Crazy")
friends = api.get_friends(screen_name = "2Wild2Crazy", count = 200)
for i in range(len(friends)):
print(""" " """, friends[i].screen_name, """ " """)
#mass follow the people who follow 2Wild2Crazy
for i in range(len(friends)):
api.create_friendship(screen_name = friends[i].screen_name)
`
Just do
#mass follow the people who follow 2Wild2Crazy
for i in range(len(friends)):
try:
api.create_friendship(screen_name = friends[i].screen_name)
except tweepy.errors.Forbidden:
print("Already following user: {}, skipping.".format(friends[i].screen_name))
Might have to import tweepy to be able to except the error. If you don't like the print command you can replace it with pass that will tell python to just ignore that specific error.
I would like to delete all the bitstreams generated by filter-media but only with a specific description "IM Thumbnail".
I am aware that I can just regenerate the thumbnail by using the -f flag to force it to regenerate the thumbnail. I am testing some settings in my setup and I would just like to delete the generated thumbnails with this specific description first.
I've tried tinkering the database via PgAdmin but I can only go as far as selecting the bitstreams. I don't even know how to group or order the returned results and not really sure if I've selected the correct tables.
SELECT
*
FROM
public.bitstream,
public.bundle,
public.bundle2bitstream,
public.metadatavalue,
public.item2bundle
WHERE
bitstream.uuid = metadatavalue.dspace_object_id AND
bitstream.uuid = bundle2bitstream.bitstream_id AND
bundle.uuid = item2bundle.bundle_id AND
bundle2bitstream.bundle_id = bundle.uuid AND
metadatavalue.text_value = 'IM Thumbnail';
Any advice on how to do this via database manipulation or any other means would be greatly appreciated. Applying the SQL deletion within a specific community or collection would be a really nice bonus too!
Thanks in advance!
Although the question was tagged with postgresql, I found the answer from DSpace Community Mailing List using Jython. Thanks for Joan Caparros for the original code. The message thread can be found here: Removing Thumbnails in DSpace 5. I also posted a similar query in the DSpace Technical Support Mailing List which can be found here: Batch delete bitstreams in the Bundle: THUMBNAIL where Joan posted a modified version of his code for my specific needs which is deleting only the thumbnails if it contains the description "IM Thumbnail". Below is the full code that achieved my goals:
from org.dspace.curate import ScriptedTask
from org.dspace.curate import Curator
from org.dspace.content.service import DSpaceObjectService
from org.dspace.content.factory import ContentServiceFactory
#from org.dspace.content.service import BitstreamService
class Main(ScriptedTask):
def init(self, curator, taskName):
print "initializing with Jython"
def performDso(self, dso):
#print "perform on dso "
if dso.getType()==2:
print "Item '" + dso.getName() + "' ("+dso.getHandle()+")"
myBundles = dso.itemService.getBundles(dso,"THUMBNAIL")
totalbundles = len(myBundles)
for i in myBundles:
myBitstreams = i.getBitstreams()
total = len(myBitstreams)
if len(myBitstreams)==0:
print "- DELETING EMPTY BUNDLE"
dso.itemService.removeBundle(Curator.curationContext(),dso,myBundles[0])
if len(myBitstreams)>0:
for k in range(0,len(myBitstreams)):
if myBitstreams[k].getDescription() == 'IM Thumbnail':
print "DELETE "+myBitstreams[0].getDescription()
bitstreamService = ContentServiceFactory.getInstance().getBitstreamService()
bitstreamService.delete(Curator.curationContext(),myBitstreams[0])
print "- DELETING BUNDLE"
dso.itemService.removeBundle(Curator.curationContext(),dso,myBundles[0])
return 0
def performId(self, context, id):
print "perform on id %s" % (id)
return 0
Please note that the code above was made as a curation task using Jython so the documentation on how to set up and use can be found here: Curation tasks in Jython.
I upload my images like this:
CloudinaryResponse response = await this.url.uploadImage(filePath,
filename: "background",
folder: "alquileres/$userId/$portfolioId/$investmentId");
The image names are "background_longID". I'd like to overwrite all the images.
I've found an old issue in Github but doesn't provide too much info (https://github.com/cloudinary/cloudinary_ios/issues/87)
You can find details about the upload and various flags for upload on the documentation page at https://cloudinary.com/documentation/image_upload_api_reference#upload_method.
If the primary concern is that you don't want Cloudinary to add the _longId parameter to the file name, you can set the flag unique_filename=false during the upload.
Another flag that you should consider is overwrite. By default, this flag is set to false. So when you re-upload, the old image is not replaced. You could set the flag overwrite=true as well to ensure that the new image is uploaded correctly.
Cloudinary doesn't support integration with flutter. there are some third parties that you can use for example here: https://gist.github.com/Wizpna/eab058e15cc1533bdb73bf764078f642
If you would like to upload images to Cloudinary, our best practice is to add an upload widget. You can read more about it here:
https://cloudinary.com/documentation/upload_widget
For someone who might be having the same issue, here is what i did
CloudinaryClient client = new CloudinaryClient(<API_KEY>, <API SECRET>, <CLOUD NAME>);
await client.uploadImage( file.path, filename: <NAME_FOR_PHOTO>, folder: <FOLDER_NAME(OPTIONAL)>)
.then((result){
print("CLOUDINARY:: ${result.secure_url}==> result");
})
.catchError((error) => print("ERROR_CLOUDINARY:: $error"));
You can use this package https://pub.dev/packages/cloudinary_public which does not require your API_KEY or API_SECRET
I'm using out-of-the-box Alfresco 4.2.f, without customizations, and i'm trying to set the email notification whether a new document in added in a certain folder.
So i've added a rule to the folder and i've set as Perform Action "Send email" using as template "notify_user_email_it.html.ftl".
If i insert a document, i don't receive the email and here is the error in the log:
Expression person is undefined on line 38, column 57 in workspace://SpacesStore/55088e2c-05ac-4264-8396-ee6f3c7021ad.
The problematic instruction:
----------
==> ${person.properties.firstName} [on line 38, column 55 in workspace://SpacesStore/55088e2c-05ac-4264-8396-ee6f3c7021ad]
----------
If i remove from the template the string ${person.properties.firstName} then the rule works properly but the mail i receive is not as expected, all the interesting informations are shown as in the original FTL. Attached the email received to understand better.
Really strange since i've not customized anything, maybe this is a BUG but i didn't find anything on JIRA...
Someone has the same behaviour? Possible work-arounds?
Thanks in advance!
According to this JIRA, it's not really a bug it just doesn't work for the admin user.
Have you tried it with a normal user?
--- Update ---
Maybe cause it's bug or an unimplemented feature something like the following to fix it in the template:
<#if person??>
.... set your person properties first & lastname
<#else>
.... is sure to be admin, so set the admin
</#if>
You have to pass the parameters to emails templates
you may try with this example
var template = "Data Dictionary/Email Templates/Workflow Notification/<<Your File>>.html.ftl";
var mail = actions.create("mail");
mail.parameters.to = "xyx#gmail.com";
mail.parameters.subject="Hello";
mail.parameters.text="blablabla";
mail.parameters.template = companyhome.childByNamePath(template);
var templateArgs = new Array();
templateArgs['workflowTitle'] = "789789";
templateArgs['workflowDescription'] = "879789";
templateArgs['workflowId'] = "879789";
var templateModel = new Array();
templateModel['args'] = templateArgs;
mail.parameters.template_model = templateModel;
mail.execute(bpm_package);
then you can get parameters using ${args.workflowTitle} in your Email template ftl file
after porting my fully working SS3.1 Page from my Webserver http://mydomain.de to my locally installed XAMPP http://intranet/silverstripe I've got the problem that the Base Directory is now wrong in SS. It's the old one from the webserver / but it need to be /silverstripe
I already changed it in the .htaccess so that mod_rewrite works but $BaseDir returns / and if I try to use the SS Sitesearch than I get redirected to home/SearchForm?Search= instead of silverstripe/home/SearchForm?Search= after submitting the form.
Can someone please help me to fix this problem.
Thank you in advance
EDIT:
I just call $SiteSearch in my Template.
But the function is modified in my Page.php to search also through a dataobject.
public function results($data, $form){
$results = $form->getResults();
$query = htmlspecialchars($data['Search'], ENT_QUOTES,'UTF-8');
$objects = ListingObject::get()->where("MATCH (Title, Link, Company, Category) AGAINST ('$query' IN BOOLEAN MODE)");
$results->merge($objects);
$data['Results'] = $results;
$data['Title'] = _t('SearchForm.SearchResults', 'Search Results');
$data['Query'] = $query;
return $this->customise($data)->renderWith(array('Page_results','Page'));
}
without this code it also doesn't work
SOLUTION:
I'm sry. I found the Problem. I didn't call $SiteSearch, because when I created the Page, I had to edit the form, so I hardcoded it... because of that, the submitted url is wrong now. I'm so sorry!
$BaseDir should be $BaseHref in your template.
You might have to set an alternate base url in the SS config. Add this to your config.yml:
Director:
alternate_base_url: '/silverstripe'