Good afternoon.
I use profile2 and the feeds_profile2 to import users from a third-party database (data in the CSV format) User profiles must be different, depending on their role, so using profile2 is the only thing that remains for me.
One of the fields is the image field. I used over 9000 import settings, used different settings of the feeds_tamper, but the only thing I get is a message about format mismatch (Invalid data value given. Be sure it matches the required data type and format. Value at profile2(6)->field_logotype:).
What am I doing wrong? Please, help. And sorry for my bad English.
Done. I imported my pictures using feeds_entity_processor, feeds_profile2 and feeds_tamper.
First I assigned obviously unused UIDs to every user in my CSV file (edited it directly in LibreOffice Calc). Then I imported profile content with default profile processor settings (mapped UID in CSV file with UID in profile field as well) without pictures URL field. Then I imported pictures separately with following feeds settings:
1) Feeds importer -> Processor -> Profile entity type - EXPERIMENTAL
2) Processor settings:
Type: desired_profile_type
Do not add new profiles
Do not skip hash check
Plain text
Skip non-existent profiles
Empty label
Empty creation date
Profile owner's ID: 0
3) Mapper settings:
photo_url_column_id -> field_image_field:url
user_manually_assigned_uid_column_id -> pid
4) Tamper settings:
plugin for PID mapper: Other -> Entity Field Query finder -> Entity type: Profile -> Field: UID
Images were updated correctly and profile2 content was updated successfully.
Related
Here is my forms.py
class AddUserForm(forms.Form):
email=forms.EmailField(label="Email",max_length=50,widget=forms.EmailInput(attrs={'placeholder':'Enter your email',"class":"form-control"}))
password=forms.CharField(label="Password",min_length=8,widget=forms.PasswordInput(attrs={'placeholder':'Enter your password',"class":"form-control"}))
name=forms.CharField(label="Name",min_length=4,max_length=20,widget=forms.TextInput(attrs={'placeholder':'Enter your name',"class":"form-control"}))
username=forms.CharField(label="Username",min_length=4,max_length=10,widget=forms.TextInput(attrs={'placeholder':'Enter a unique username',"class":"form-control"}))
gender_choice=(
("Male","Male"),
("Female","Female")
)
manegers=Manager.objects.all()
maneger_list=[]
for maneger in manegers:
small_maneger=(maneger.id,maneger.name)
maneger_list.append(small_maneger)
staffs=Staff.objects.all()
staff_list=[]
for staff in staffs:
small_staff=(staff.id,staff.name)
staff_list.append(small_staff)
manager_idd=forms.ChoiceField(label="Manager",choices=maneger_list,widget=forms.Select(attrs={"class":"form-control"}))
staff_id=forms.ChoiceField(label="Staff",choices=staff_list,widget=forms.Select(attrs={"class":"form-control"}))
cnic=forms.CharField(label="Cnic",max_length=13,min_length=13,widget=forms.TextInput(attrs={'placeholder':'xxxxxxxxxxxxx',"class":"form-control"}))
gender=forms.ChoiceField(label="Gender",choices=gender_choice,widget=forms.Select(attrs={'placeholder':'Select',"class":"form-control"}))
contact_number=forms.CharField(label="Contact#",max_length=10,min_length=10,widget=forms.TextInput(attrs={'placeholder':'+92xxxxxxxxxx (enter 10 digits)',"class":"form-control"}))
I have to reload server again and again when I put data otherwise choice field does not show update name. I want to remove this thing. Is thing problem will be continued when I deploy my website to host.
Is there anyway of uploading Custom Slot Types values via an API, so that you do not need to type them in manually using the new Alexa Skill Builder interface (if you have many of them):
I haven't found anything.
My recommendation is to get the model via SMAPI first, edit the json file with your new values and update it via SMAPI again.
ask api get-model -s "enter your skill id here" --stage development -l en-US > model.json
in the model.json file you can see the slots definition. Change it (with a script or manually) and update the model again
Reference to both commands:
https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html#update-model-subcommand
https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html#update-model-subcommand
It seems not (after searching). There is a feature request logged here with Amazon:
https://forums.developer.amazon.com/questions/9640/api-to-upload-intent-schema-and-sample-utterances.html#answer-77902
Yes you can do this via the SMAPI API/CLI. Take a look at https://developer.amazon.com/docs/smapi/ask-cli-intro.html for a full detail - it allows for full model editing via JSON.
In the left bar bellow the "Intents" and "Slot" is the option "JSON Editor". There you can write a JSON for the new intents you want to add.
Example without slot type
{
"name":"YesIntent",
"samples":[
"Yes",
"Yeah",
"I do",
"I am"
]
}
Example with slot type
{
"name":"NumberIntent",
"slots":[
{
"name":"number",
"type":"AMAZON.NUMBER"
}
],
"samples":[
"{number} is my number",
"{number}",
"my number is {number}"
]
}
As other answers suggest, you can use the SMAPI.
Alternatively, you can select the "code editor" tab on the left and drag/drop or copy/paste your schema json code.
https://github.com/williamwdu/Alexa-Custom-Slot-Generator
I wrote this to convert csv/excel to JSON format so you can paste it into code editor.
Let me know if you have any question.
There is no README for the code coz I have no time these days
I am developing a vb.net winform project that takes a persons photo ID. I want to store the location of the photo in a SQL Server database.
In the project, a persons details are taken (Name, Number, Address, etc) and stored in the database. I can do that part no problem. A photo is taken of the person and stored in a folder on one of the drives on the network. There is an option to choose a photo from this folder in the project and it is added to the profile.
What is the best way to get the location of the image and how do I go about storing it in the Sql server database? I want to be able to use the location of the photo to call it to use again in another part of the project. Any help with this problem would be greatly appreciated.
In your application, your going to want to use a "OpenFileDialog" so the user can choose the file. See example below:
Dim ofd As New OpenFileDialog
ofd.Filter = "*.png|PNG|*.jpg|JPEG" 'Add other exensions you except here
ofd.Title = "Choose your folder"
'ofd.InitialDirectory = "c:\SomeFolder..." 'If you want an initial folder that is shown, otherwise it will use the last folder used by this appliaction in an OFD.
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
'Something = ofd.FileName 'Do something with the result
End If
Then save the result of ofd.FileName in your table. This will be the full path and name of the file they selected.
I run a site that operates the same on many URLs except for the name and the display of objects tied to a given site. Because of this I have extended the Site model to include various other bits of information about a site and created a middleware to put the standard Site object information into the request object. Previously the only info I needed in the request object was the site's name, which I could get from the Site models Django provides. I now need bits of information that reside in my extended Site model (which previously was only used by my other various app models).
This goes from adding one query to each page (request.site = Site.objects.get_current()) to adding two, as I need to get the current site, then get the associated extended Site object from my model.
Is there a way to get this information without using two queries? Or even without using one?
models.py:
from django.contrib.sites.models import Site
class SiteMethods(Site):
"""
Extended site model
"""
colloquial_name = models.CharField(max_length=32,)
...
middleware.py:
class RequestContextMiddleware(object):
"""
Puts the Site into each request object
"""
def process_request(self, request):
# This runs two queries on every page, instead of just one
request.site = SiteMethods.objects.get(id=Site.objects.get_current().id)
return None
In my settings.py file, I have all shared configuration data. My server instances (gunicorn) are configured to load [site]_settings.py, which holds all site-specific settings (to include Django's SITE_ID), and at the bottom:
try:
from settings import *
except ImportError:
pass
I am looking for options (if they exist) that do not include referencing the hard-coded SITE_ID in [site]_settings.py.
Update:
As suggested below, subclassed objects should still have access to their parent objects and all the parent object's functionality. For the Site object, strangely, this seems to not be the case.
>>> Site.objects.get_current()
<Site: website.com>
>>> SiteMethods.objects.get_current()
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'Manager' object has no attribute 'get_current'
>>> SiteMethods.objects.select_related('site').get_current() # as suggested below
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'QuerySet' object has no attribute 'get_current'
>>> dir(SiteMethods)
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__',
'__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__',
'__metaclass__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__',
'__weakref__', '_base_manager', '_default_manager', '_deferred', '_get_FIELD_display',
'_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val',
'_get_unique_checks', '_meta', '_perform_date_checks', '_perform_unique_checks',
'_set_pk_val', 'clean', 'clean_fields', 'date_error_message', 'delete', 'full_clean',
'objects', 'pk', 'prepare_database_save', 'save', 'save_base', 'serializable_value',
'site_ptr', 'sitemethods', 'unique_error_message', 'validate_unique',]
Since you subclassed Site you should be able to just do SiteMethods.objects.get_current(), which will net you an instance of SiteMethods. Since Django's implementation of MTI (Multiple Table Inheritance) uses a OneToOneField to the parent class, you should also be able to use select_related for site. So, try the following:
SiteMethods.objects.select_related('site').get_current()
A caveat to begin with - I don't actually know if what I want to do is possible, particularly because I'm not well versed with LDAP/Active Directory or JIRA.
I'm trying to integrate my shiny new installation of JIRA with my existing active directory. What I want to do is set up some specific JIRA groups (e.g. in London\Security Groups\JIRA*) and then have JIRA only import the users who have membership of those groups. However, in the directory set up page in JIRA, I don't understand how to do this. It seems to indicate that I can import users and groups, but not users from groups.
What am I missing? (apart from expert level knowledge of AD!)
Update
Under my domain, I have an organisational structure like this:
London\Users
London\Security Groups\JIRA
Under the latter organisational unit, I have a security group called "jira-users". The former contains all users.
So far I've tried the following queries and none of them have worked :
(all prefixed with &(objectCategory=Person)(sAMAccountName=*)")
memberof=CN=jira-users,ou=London,ou=Security Groups,ou=JIRA,dc=mycompany,dc=local
memberof=CN=JIRA,ou=London,ou=Security Groups,dc=mycompany,dc=local
(prefixed with just &(objectCategory=Person)")
memberof=CN=jira-users,ou=London,ou=Security Groups,ou=JIRA,dc=mycompany,dc=local
Completed
The query that works is this :
memberof=CN=jira-users,OU=JIRA,OU=Security Groups,OU=London,DC=mycompany,DC=local
I hadn't realised that for a folder structure that is logically, left to right, London\Security Groups\JIRA, the organisational units need to be listed in reverse order.
Further Update
This only works when using the DirectorySearcher class for some reason, e.g.
DirectoryEntry rootEntry = new DirectoryEntry("LDAP://dc=mycompany,dc=local");
DirectorySearcher srch = new DirectorySearcher(rootEntry);
srch.SearchScope = SearchScope.Subtree;
srch.Filter = "(&(objectCategory=Person)(sAMAccountName=*)(memberof=CN=jira-users,ou=London,ou=Security Groups,ou=JIRA,dc=mycompany,dc=local))";
SearchResultCollection results = srch.FindAll();
This doesn't work in the LDAP explorer tool and subsequently, not in JIRA itself.
Last Update
So...for JIRA, you need to reverse the order AND remove the wildcard. Working query in the end is :
(&(objectCategory=Person)(memberof=CN=jira-users,OU=JIRA,OU=Security Groups,OU=London,DC=mycomapny,DC=local))
When you are setting up the user directory look under the User Schema settings. You should see a "User Object Filter" field. In there you should be able to add something like this:
(memberOf=cn=jira-users,ou=London,dc=mydomain,dc=com)
This will allow you to filter based on a specific LDAP group. Of course you will need to edit the values above to reflect your own environment.