user-profile interview questions
Top user-profile frequently asked interview questions
I want to add a menu item along side the [view] [edit] [files] ... menu links at the top of the user profile page. When a user clicks it, it should behave like the others, in that it doesn't just launch to a new page, but the menu item they clicked on (let's call it "Funky Button") turns greyish and the user remains in the user profile area.
I've created a hook like below:
function my_module_funky() {
// TODO: what to do?
}
function my_module_menu() {
$items['user/%user/funky'] = array(
'title' => t('Funky Button'),
'page callback' => 'my_module_funky',
'page arguments' => array(1),
'access callback' => TRUE,
'access arguments' => array('access funky button'),
'type' => MENU_LOCAL_TASK,
);
return $items;
}
So this above code snippet adds the button -- but I can't figure out how to get it to display like the view and edit buttons display their content. Thanks!
Source: (StackOverflow)
How to Create Profile Property Through Code in DNN (DotNetNuke)?
I tried this code:
DotNetNuke.Entities.Profile.ProfilePropertyDefinition def =
DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(this.PortalId, "Level");
if (def != null)
{
def.DataType = 10;
def.Length = 40;
def.PropertyValue = "Level";
def.PropertyName = "Level";
oUser.Profile.ProfileProperties.Add(def);
}
oUser.Profile.SetProfileProperty("Level", ddlLevel.SelectedItem.Text.ToString().Trim());
DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(oUser, oUser.Profile.ProfileProperties);
But it won't work, please help me with suitable solution.
Source: (StackOverflow)
I'm creating a web application using MVC 5 and Identity. I have so far created a registration system, but I would like to allow users to upload a profile when they register.
I was wondering if it is possible to implement profile pictures with asp.net identity?
Source: (StackOverflow)
Is there any method to search for FB User ID from email Address ?
Am developing a site where I would like to show the User Profile Pic based on his Email address - if the person is registered and the Profile Pic is made public.
Have tried searching - but am unable to get to any solution - where we can search for User ID - based on Email ID.
It is like how the Social Connect Plugin functions for Outlook 2010.
Thanx !
Source: (StackOverflow)
I am merely trying to use the GetUserProfileByName service to get some details on a user from the AD. For this I opted to use javascript. After a little bit of research, and a significant amount of tinkering, I managed to connect to the webservice and successfully retrieve the data.
I used a simple if statement to compare the 'name' of the property in order to get the specific value I want.
if(xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue == "Department")
{
property = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue;
}
At this point I started noticing some discrepancies. I seemed to not be getting the property I specify in the comparison. For example if I specify "Department" it returns the email. After a lot of struggling i finally decided to just drop all the "Name" and "Value" fields into two arrays without any comparison and display them next to each other.
for(i = 0; i < 13 ; i++)
{
description[i] = xmlDoc.getElementsByTagName("Name")[i].childNodes[0].nodeValue;
elements[i] = xmlDoc.getElementsByTagName("Value")[i].childNodes[0].nodeValue;
}
The conclusion I got from this was that the two fields clearly did not match up with each other:
UserProfile_GUID: 65f017dc-b892-4afa-8730-5e8f73aa7b86
AccountName: CAPETOWN\ANEL5
FirstName: Abraham
SPS-PhoneticFirstName: Nel
LastName: Abraham Nel
SPS-PhoneticLastName: 021 ### ####
PreferredName: CRS - Info Sys & Tech
SPS-PhoneticDisplayName: Contractor
WorkPhone: Contractor
Department: ANEL5
Title: CN=Abraham Nel,OU=Standard,OU=Users,OU=End-User Services,DC=###,DC=###,DC=###
SPS-JobTitle: ###@###.###
Manager: Cape Town Civic Centre Podium Block
Any idea why this would be happening?
Result from trying to parse the entire XML document to string:
falsefalseUserProfile_GUIDNotSetb21ec99c-2ad9-40a8-9d45-a3273c92ee5afalsefalseAccountNameNotSetCAPETOWN\AHEYNESfalsefalseFirstNameNotSetAshleyfalsefalseSPS-PhoneticFirstNameNotSetfalsefalseLastNameNotSetHeynesfalsefalseSPS-PhoneticLastNameNotSetfalsefalsePreferredNameNotSetAshley HeynesfalsefalseSPS-PhoneticDisplayNameNotSetfalsefalseWorkPhoneNotSet021 400 ####falsefalseDepartmentNotSetCRS - Info Sys & TechfalsefalseTitleNotSetAssistant Professional OfficerfalsefalseSPS-JobTitleNotSetAssistant Professional OfficerfalsefalseManagerNotSetCAPETOWN\DSISSINGfalsefalseAboutMeNotSetfalsefalsePersonalSpaceNotSetfalsefalsePictureURLNotSetfalsefalseUserNameNotSetAHEYNESfalsefalseQuickLinksNotSetfalsefalseWebSiteNotSetfalsefalsePublicSiteRedirectNotSetfalsefalseSPS-Dotted-lineNotSetfalsefalseSPS-PeersNotSetfalsefalseSPS-ResponsibilityNotSetfalsefalseSPS-SipAddressNotSetfalsefalseSPS-MySiteUpgradeNotSetfalsefalseSPS-ProxyAddressesNotSetfalsefalseSPS-HireDateNotSetfalsefalseSPS-DisplayOrderNotSetfalsefalseSPS-ClaimIDNotSetfalsefalseSPS-ClaimProviderIDNotSetfalsefalseSPS-ClaimProviderTypeNotSetfalsefalseSPS-SavedAccountNameNotSetfalsefalseSPS-ResourceAccountNameNotSetfalsefalseSPS-ObjectExistsNotSetfalsefalseSPS-MasterAccountNameNotSetfalsefalseSPS-DistinguishedNameNotSetCN=Ashley Heynes,OU=Developers,OU=Users,OU=End-User Services,DC=##,DC=##,DC=##falsefalseSPS-SourceObjectDNNotSetfalsefalseWorkEmailNotSet##.##@##.##.##falsefalseCellPhoneNotSetfalsefalseFaxNotSetfalsefalseOfficeNotSetCape Town Paul Sauer BuildingfalsefalseSPS-LocationNotSetfalsefalseSPS-TimeZoneNotSetfalsefalseAssistantNotSetfalsefalseSPS-PastProjectsNotSetfalsefalseSPS-SkillsNotSetfalsefalseSPS-SchoolNotSetfalsefalseSPS-BirthdayNotSetfalsefalseSPS-StatusNotesNotSetfalsefalseSPS-InterestsNotSetfalsefalseSPS-EmailOptinNotSet
Source: (StackOverflow)
I have a rails 3 devise app has users with a profile and privacy settings. I currently have this working, but am concerned about efficiency and would love the advice of an experienced rails dev.
I generated User model with devise and scaffolded out Profile and Privacy models to contain items deemed not required for sign up. I would like the the User to have different settings links.
Account Settings => Devise - just required login type stuff, username, password
Profile Settings => Profile model - description, avatar, birthday etc.
Privacy Settings => Privacy model - checkboxes that control basic hiding/showing of the user's profile fields.
I have set up my relationships:
user.rb
has_one :profile
has_one :privacy
profile.rb
belongs_to :user
privacy.rb
belongs_to :user
This seems horribly inefficient to me. To display the profile I am relying on loading three tables: users, profiles, and privacies.
I think that all of the table columns from Profile and Privacy should be contained in the users table, would this make more sense? How would I separate the different forms?
My one thought was to just add a profile method and a privacy method to the users controller, than I could make profile and privacy templates in my users views. with different forms controlling the different portions of the user record that each would edit.
Does this make sense? Would this make more sense than separate scaffolds like I currently have?
Source: (StackOverflow)
How do I edit link tabs found on the default user profile page in drupal? I'm trying to avoid having to create a user_profile.tpl.php file and rebuild the entire profile from scratch. If there's an easier way to do this, I'd rather do that. But, if I'm forced to create a custom template, how do I control the menu tabs for the profile? I haven't found any documentation that explains that part yet.
Source: (StackOverflow)
I've writing a Django site that uses two different databases. One is the local, let's call it, "Django", database that stores all of the standard tables from a pretty standard install -- auth, sites, comments, etc. -- plus a few extra tables.
Most of the data, including users, comes from a database on another server, let's call it the "Legacy" database.
I'm looking for suggestions on clean, pythonic ways of connecting the two databases, particularly in regards to users.
I'm using a proxy model, which works great when I can explicitly use it, but I run into problems when I'm accessing the user object as a related object (for example, when using the built-in django comments system).
Here's what the code looks like:
models.py: (points to the Django database)
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User as AuthUser, UserManager as AuthUserManager, AnonymousUser as AuthAnonymousUser
class UserPerson(models.Model):
user = models.OneToOneField(AuthUser, related_name="person")
person_id = models.PositiveIntegerField(verbose_name='Legacy ID')
def __unicode__(self):
return "%s" % self.get_person()
def get_person(self):
if not hasattr(self, '_person'):
from legacy_models import Person
from utils import get_person_model
Person = get_person_model() or Person
self._person = Person.objects.get(pk=self.person_id)
return self._person
person=property(get_person)
class UserManager(AuthUserManager):
def get_for_id(self, id):
return self.get(person__person_id=id)
def get_for_email(self, email):
try:
person = Person.objects.get(email=email)
return self.get_for_id(person.pk)
except Person.DoesNotExist:
return User.DoesNotExist
def create_user(self, username, email, password=None, *args, **kwargs):
user = super(UserManager,self).create_user(username, email, password, *args, **kwargs)
try:
person_id = Person.objects.get(email=email).pk
userperson, created = UserPerson.objects.get_or_create(user=user, person_id=person_id)
except Person.DoesNotExist:
pass
return user
class AnonymousUser(AuthAnonymousUser):
class Meta:
proxy = True
class User(AuthUser):
class Meta:
proxy=True
def get_profile(self):
"""
Returns the Person record from the legacy database
"""
if not hasattr(self, '_profile_cache'):
self._profile_cache = UserPerson.objects.get(user=self).person
return self._profile_cache
objects = UserManager()
legacy_models.py: (points to the "Legacy" database)
class Person(models.Model):
id = models.AutoField(primary_key=True, db_column='PeopleID') # Field name made lowercase.
code = models.CharField(max_length=40, blank=True, db_column="person_code", unique=True)
first_name = models.CharField(max_length=50, db_column='firstName', blank=True) # Field name made lowercase.
last_name = models.CharField(max_length=50, db_column='lastName', blank=True) # Field name made lowercase.
email = models.CharField(max_length=255, blank=True)
def __unicode__(self):
return "%s %s" % (self.first_name, self.last_name)
def get_user(self):
from models import User
if not hasattr(self,'_user'):
self._user = User.objects.get_for_id(self.pk)
return self._user
user = property(get_user)
class Meta:
db_table = u'People'
I've also whipped up my own middleware, so request.user
is the proxy User
object also.
The real problem is when I'm using something that has user as a related object, particularly in a template where I have even less control.
In the template:
{{ request.user.get_profile }}
{# this works and returns the related Person object for the user #}
{% for comment in comments %} {# retrieved using the built-in comments app %}
{{ comment.user.get_profile }}
{# this throws an error because AUTH_PROFILE_MODULE is not defined by design #}
{% endfor %}
Short of creating a wrapped version of the comments system which uses my proxy User model instead, is there anything else I can do?
Source: (StackOverflow)
I am trying to fetch facebook a user's profile page using "wget" but keep getting a non-profile page called "browser.php" which has nothing to do with that particular user. The profile page's URL as I see in the browser happens to be of the following format:
http://www.facebook.com/user-name
and that's what I have been using as the argument to the wget command:
wget http://www.facebook.com/user-name
I am also interested in using wget to fetch a user's friends' list but even that is giving me the same unhelpful result ("browser.php"):
wget http://www.facebook.com/user-name?sk=friends&v=friends
Could someone kindly advise me what I'm doing wrong here? In other words, am I missing out some key options for wget command or does wget not fit such a scenario at all?
Any help will be greatly appreciated.
To add context to this query, I need to figure out how to fetch these pages from Facebook using wget as it would then help me write a script/program to look up friends' profile URLs from the HTML source code and then look up some other keywords on them, etc. I am basically hoping that this would help me in doing some kind of selective-crawling (with Facebook's permission of course) of people I am not connected to.
Source: (StackOverflow)
I have been trying to use django-allauth to provide Social registration, but I am having trouble configuring the profiles for the user. There is no documentation of django-allauth which tells
- how a django user account is created when a user logs in via a third party such as facebook
- What username is assigned to that user and what password is used.
- Certain third party providers such as Facebook provide a lot of information about the user such as their name, email etc. so how can we get them and save in the user account/profile
If anybody has used allauth in their projects and can provide some details then it would be really helpful.
Source: (StackOverflow)
I've done MVC in the past, but I am new to ASP and ASP MVC. I really love the ease that ASP MVC provides me, so far, but I am having trouble figuring out how to get more control over the Users. By default, the MVC provides a minimal user registration form. I have looked around quite a bit, but I still have two questions:
How do I make the User data base a local database in my project? I think SQLEXPRESS is used to store the user values, in what seems like a magical process. How do I de-magic-ify this? I would like to have more control on the location of this database.
This leads to another question: How do I expand the User? I have been reading up on Profiles, but I am still confused about a few things. How do I prepare a Profile and link it with a User? What serves as the foreign key? And, in my controllers, how can I access various parts of the user like username, email, or even from the profile stuff like firstname, lastname (though I guess once when I have a Profile's database and a User's database locally, I can run sql commands to retrieve data)
I would really appreciate some pointers to the right resources, and/or best practices with ASP.NET
Source: (StackOverflow)
How can I change the gravatar associated with my nuget.org profile? I have noticed other users have photo's as their avatar.
I have created a profile on nuget.org and uploaded a package.
Source: (StackOverflow)
I've used bash for two years, and just tried to switch to zsh shell on my OS X via homebrew. And I set my default (login) shell to zsh, and I confirmed it's set properly by seeing that when I launch my Terminal, it's zsh shell that is used in default.
However, when I try to enter bash shell from within zsh, it looks like not loading ~/.bash_profile
, since I cannot run my command using aliases, which is defined in my ~/.bash_profile
like alias julia="~/juila/julia"
, etc.. Also, the prompt is not what I set in the file and instead return bash-3.2$
.
For some reasons, when I set my login shell to bash, and enter zsh from within bash, then ~/.zshrc
is loaded properly.
So why is it not loaded whenever I run bash
from within zsh? My ~/.bash_profile
is symbolic linked to ~/Dropbox/.bash_profile
in order to sync it with my other computers. Maybe does it cause the issue?
Source: (StackOverflow)
Trynig to add a new, persistent, Firefox profile with Selenium. AFAIK, when executing FirefoxProfile()
, a new profile is generated using a temporary file. Ideally, this profile should be able to remain available to subsequent processes - even after the creator is closed.
Problem:
- Create a new Firefox profile from within Python code. This should return a FirefoxProfile object that is usable with the Firefox webdriver Selenium uses.
- The profile created should persist after the process ends - i.e. it should be a full-fledged profile, not just a temporary profile.
Some pointers:
The profiles.ini
file seems to be key. I have read some code that uses the Java class ProfilesIni
to modify profile information. If this class is available for Python code, it should probably take care of most of this.
If the only way to do this is to manually modify the profiles.ini
file, that's acceptable. A better, more standardized solution (one that uses a library or Selenium code) would be preferable, however.
Thanks very much!
Source: (StackOverflow)
I found two ways of implementing a symmetrical friendship system (you are my friend, so I am also your friend) in Django:
As suggested inside the docs:
class UserProfile(models.Model):
friends = models.ManyToManyField(User, related_name='friends')
Now, I'd like to get all "friendly" user AND userprofile models with one select_related-query like so (that should be a reverse joined lookup):
profiles = UserProfile.objects.filter(user__in=request.user.get_profile().friends.all()).select_related()
I query the userprofile, because that way, I can use select_related() and all related objects are cached.
On the other hand, I can define my model referencing the friends field to "self", like so:
class UserProfile(models.Model):
friends = models.ManyToManyField('self')
Now, my select_related friend lookup looks like that:
profiles = this_user.get_profile().friends.all().select_related()
I always need both, the user object and it's related profile: The second approach is much simpler concerning the reversed lookup via select_related(), but does practically the same. However, by using "self" as field reference, Django handles for me the symmetrical friendship. Thus, I don't have to create two entries per friendship in the database manually. Django does that for me. The symmetrical option, however, does only work on "self" referencing fields.
Which is the better solution? I can't find anything about it. Any ideas appreciated - thanks!
Source: (StackOverflow)