I'm trying to get the logged in user's id from self._uid. But when I logged in with a user and I got the user_id = 1 (which is the user_id of the administrator account)
That is my line. Am I doing something wrong?
user_id = self._uid
Replace your code
from
user_id = self._uid
to
user_id = self.env.user
These will give us current logged user as a recordset. So if you need id, get it like self.env.user.id
Related
can I call a function in USERNAME_FIELD = '' to create an optional choice for login, using email or phone number? if yes how?
yes, you can
you can write special login function in your view and use query like this :
user = User.objects.filter(Q(email=value)|Q(username=value)).first()
login(request, user)
I use Q django db functions to complex query and I can use Or in my queries for example in up code I filter email equal by value or username equal by value so if uaer enter username or email I can find him
in other ways I can use two query but its not common
like this :
user_by_username=User.objects.filter(usernsme=value).first()
if user_by_username:
login(request,user)
else:
user_by_email=User.objects.filter(email=value).first()
if user_by_email:
login(request,user_by_email)
and default user model hasn't mobile field you can save mobile as username or create special usermodel
or create new model for your user profile
I am doing automation on Jira, now I want fetch the data from tickets, but the tickets must have the customfield_10030, otherwise the tickets should not be selected.
Below is the code, I am using, please help me out
from atlassian import Jira
jira_instance = Jira(
url = "https://xxxxxxx.atlassian.net/",
username = "username#gmail.com",
password = "API token",
)
data = jira_instance.jql("project = ProjectName AND status = 'Open' ORDER BY created ASC")
The above code fetches all the tickets in open status under the project. But I want to fetch all the tickets in open status and has the customfield_10030, only then it should be selected.
Please help me out in this
JQL:
customfield_10030 is not empty
The JQL would be: project = ProjectName AND status = 'Open' AND cf[10030] is not empty ORDER BY created ASC
It's best to refer to custom fields by their ID, not their name, in case someone changes the name or there are other fields with the same name.
We can get the roles of an SPUser by SPUser.Roles. But it will return SPRoleCollection. If we want to list all the roles we need to loop that.
For example an User has "Full Control","Read","Design" we need to loop the SPRoleCollection object.
How can i get all the roles as a string with ',' separator?
As a rough guess, try:
var user = SPUser // However you get the user.
var roles = Sring.Join(",", (from r in user.Roles select r.Name).ToArray()));
Though if you're using SharePoint 2010, the Name property is obsolete apparently.
How do I query for all trac tickets related to a user. i.e. all tickets for which the tickets were once assigned, assigned now, created , etc etc
Create custom queries to the ticket_change table. Some SQL required. For assigned once/now, look for rows where field='owner', newvalue column contains the user name the ticket was assigned to. For created tickets, just query by reporter in the ticket table.
Example:
SELECT p.value AS __color__,
id AS ticket, summary, component, version, milestone,
t.type AS type, priority, t.time AS created,
changetime AS _changetime, description AS _description,
reporter AS _reporter
FROM ticket t, enum p, ticket_change c
WHERE p.name = t.priority AND p.type = 'priority'
AND c.field = 'owner'
AND c.newvalue = '$USER'
AND c.ticket = t.id
ORDER BY p.value, milestone, t.type, t.time
You can express this with a TraqQuery expression. E.g. if you want the columns id, summary and status to show up and query all the tickets for the currently logged in user ($USER) then use the following query.
query:?col=id
&
col=summary
&
col=status
&
owner=$USER
However this query assumes that the owner hasn't been the same during the lifetime of a ticket (since ownership can be changed).
If you want a specific user then replace $USER with the actual username. Also if you're using the Agilo plugin you can easily create new queries on the fly via the web-UI. This is done by looking at a report and adding filters to the report.
I'm currently working with the versant object database (using jvi), and have a case where I need to query the database based on an object id.
The problem is I'm running some performance tests on the database using the pole position framework, and one of the tests in that framework requires me to fetch an object from the database using either an object reference or a low level object id. Thus, I'm not allowed to reference specific fields in the employee object, but must perform the query on the object in its entirety. So, it's not allowed for me to go "select * from Employee e where e.id = 4", I need it to use the entire object.
What I'm trying to achieve is something along the lines of
Employee employee = new Employee("Mr. Pickles");
session.commit();
FundVQLQuery q = new FundVQLQuery(session,
"select * from Employee employee where employee = $1");
q.bind(employee);
q.execute();
However, this throws an EVJ_NOT_A_VALID_KEY_TYPE error. Does anyone know the correct way of doing this?
Sure you figured this out (post was months ago). What you want to do is use the GetObjectId first, to get the VOD Id of the object, then query the DB;
id = session.GetObjectId(employee);
This is how I did the whole roundtrip object → OID → object:
First you get the OID with TransSession.getOidAsLong.
TransSession session = ...;
Employee employee = new Employee("Mr. Pickles");
long oid = TransSession.getOidAsLong(employee);
session.commit();
Once you have the object ID, just grab the object from its Handle.
TransSession session = ...;
Employee employee = (Employee)session.returnHandleFromLong(oid).handleToObject();
No VQL needed.
Usually keys are integers and not strings. You are creating an Employee using just his name, perhaps the correct identifier to use is his employeeId. I need some more information on the table to know for sure.
You can try this,
FundVQLQuery vql = FundVQLQuery (session,
"select selfoid from Employee where name = $1");
vql.bind ("Mr. Pickles");
HandleEnumeration e = vql.execute ();
while ( e.hasmoreHandles() ) {
Handle handle = e.nexthandle();
}
It will return all Employees with the name "Mr. Pickles", Then loop through them.