I want to design a simple app using Django. The design is as follows:
Each user has their own unique ID in the database called id which exists in the auth_user table already equipped with Django. Then I have a Team_ID which is another unique id that represents a team in table called team_profile. In this table I have the following columns: Member1, Member2, Member3. Currently, a user can create a team and this will set Member1 to the id if the creator.
Each user also has a profile page and in this profile page their is an invite button. This is where I am stuck. I am trying to write the invite function but I have absolutely no idea where to start. In the ideal world, I would like a notification to be sent to the invitee and the invitee can accept or decline the invitation. If the member accepted the invitation then Member2 will have this person's id. I am currently reading up on a lot of stuff but in the meantime if anyone of you guys have any suggestions that would be great.
There are multiple way to engineer your problem, I'm gonna suggest one, but eventually you may adapt it to your need ( i don't know your project in dept )
TeamMembership:
user1: user that send the request
user2: user that receive the request
status: here you can create a choice field where 1=pending, 2=accepted, 3=declined
The next thing you have to do is to manage the membership filtering based on the status.
This is a minimalistic approach that you can extend with for example the date of the invite etc.
Related
I need to get a list of all friends' names and birthdates from facebook to make a program to automatically send out birthday messages, but even after going through the facepy, and facebook documentation I couldn't find anything up to date that works.This is the closest i have gotten, this returns the amount of friends I have.
from facepy import GraphAPI
graph = GraphAPI('user_token')
query = graph.get("me")['name'] # user's name
print(query)
friend_count = graph.get("me/friends")['summary']['total_count'] # user's friend count
print(friend_count)
Getting all friends is not possible anymore, since many years. You can only get friends who authorized your App too, and they need to authorize with the correct permission.
Automatically sending messages would not be possible anyway for other reasons too, there is no API to automatically send messages from user to user, for example.
I found it
GET
https://graph.facebook.com/v13.0/me?fields=friends%7Bbirthday%7D&access_token=
it doesn't get information when in "self" mode
I'm a newbie in Django and I'm building this web app that allows three different types of users to login. A customer, operator and an accountant. When the customer logs in, he is asked to upload two jpeg documents. When he is done, these documents will be converted into editable text(I'm using Google's Tesseract engine for Optical character recognition for this) and this data is stored in three columns. The first two columns are non editable but the third is editable. In the third column, the user makes changes if the converted text has any errors(since OCR is not 100 % accurate).
At this point an email has to be sent to the operator. The operator logs in and checks whether the customer has uploaded the the right documents or not. If there are any errors, he edits them and hits the save button. At this stage an email is sent to the accountant and he logs in to verify the data for the second time. If he confirms, an email is sent to the customer saying his documents have been verified.
As of now, my app is taking an image and converting it into editable text and displaying it in an HTML template. I need to know how to store this text in a table of three columns and make it available for the operator and accountant to edit. And also, I need to know how to make three different types of logins for three different users.
Please help. I will really appreciate it.
You could've edited your question better but still, I'll try to answer as much as I understood:
Firstly let's start with the login. So, what you want is role-based login which you can easily achieve through Django auth_user and user_group. In this, you'll create a user through Django built-in auth system (django authentication) and after this assign a group to every user you create so that when you log in a user you can redirect him accordingly.
Next, you mentioned that you wanted to save data in DB. For that, you'll need to connect a DB through Django settings (my preference PostgreSQL) and then you have to create models according to your need (django models).
Lastly, for data read and write operations in DB you can look at Django ORM (django ORM)
I am having a baby soon and I want to give him a unique/relatively less known name from my country. I want to get all names on facebook for a given country (say India) and then find 1000 least common names. I am not able to determine if Facebook API allows me to do this. Can someone suggest which APIs I should look at?
If it is not possible in FB, is it possible in any other social network?
Thanks.
The Graph API. Although I think Graph API takes reference from a user and then search in his friends only or if he/she has a page then in their followers only. The users which are not connected to the user can not be accessed. I've never seen a function which can return all users or their userIDs.
Edit:-
Ok I've found that you might need the Open Graph API and the Action Types, but their's no Action type for country.
This isn't possible. The closest you can do is an FQL query on the name table
SELECT name FROM user WHERE contains('user763410baby')
I'm using Google App Engine NDB. Sometimes I will want to get all users with a phone number in a specified list. Using queries is extremely expensive for this, so I thought I'll just make the id value of the User entity the phone number of the user so I can fetch directly by ids.
The problem is that the phone number field is optional, so initially a User entity is created without a phone number, and thus no value for id. So it would be created user = User() as opposed to user = User(id = phone_number).
So when a user at a later point decides to add a phone number to his account, is there anyway to modify that User entity's id value to the new phone number?
The entity ID forms part of the primary key for the entity, so there's no way to change it. Changing it is identical to creating a new entity with the new key and deleting the old one - which is one thing you can do, if you want.
A better solution would be to create a PhoneNumber kind that provides a reference to the associated User, allowing you to do lookups with get operations, but not requiring every user to have exactly one phone number.
I have a user input form here:
http://www.7bks.com/create (Google login required)
When you first create a list you are asked to create a public username. Unfortuantely currently there is no constraint to make this unique. I'm working on the code to enforce unique usernames at the moment and would like to know the best way to do it.
Tech details: appengine, python, webapp framework
What I'm planning is something like this:
first the /create form posts the data to /inputlist/ (this is the same as currently happens)
/inputlist/ queries the datastore for the given username. If it already exists then redirect back to /create
display the /create page with all the info previously but with an additional error message of "this username is already taken"
My question is:
Is this the best way of handling server side validation?
What's the best way of storing the list details while I verify and modify the username?
As I see it I have 3 options to store the list details but I'm not sure which is "best":
Store the list details in the session cookie (I am using GAEsessions for cookies)
Define a separate POST class for /create and post the list data back from /inputlist/ to the /create page (currently /create only has a GET class)
Store the list in the datastore, even though the username is non-unique.
Thank you very much for your help :)
I'm pretty new to python and coding in general so if I've missed something obvious my apologies.
Tom
PS - I'm sure I can eventually figure it out but I can't find any documentation on POSTing data using the webapp appengine framework which I'd need in order to do solution 2 above :s maybe you could point me in the right direction for that too? Thanks!
PPS - It's a little out of date now but you can see roughly how the /create and /inputlist/ code works at the moment here: 7bks.com Gist
I would use Ajax to do an initial validation. For example as soon as the user name input box loses focus I would in the background send a question to the server asking if the user name is free, and clearly signal the result of that to the user.
Having form validation done through ajax is a real user experience delight for the user if done correctly.
Of course before any of the data was saved I would definitely redo the validation server side to avoid request spoofing.
jQuery has a nice form validation plugin if you are interested. http://docs.jquery.com/Plugins/validation.
In my career, I've never gotten around having to validate server side as well as client side though.
About the storing of the list (before you persist it to the datastore). If you use ajax to validate the user name you could keep the other fields disabled until a valid user name is filled in. Don't allow the form to be posted with an invalid user name!
That would perhaps solve your problem for most cases. There is the remote possibility that someone else steals the user name while your first user is still filling in his list of books. If you want to solve that problem I suggest simply displaying the list as you got it from the request from the user. He just sent it to you, you don't have to save it anywhere else.
Can you use the django form validation functionality (which I think should just abstract all this away from you):
http://code.google.com/appengine/articles/djangoforms.html
Search in that page for "adding an item" - it handles errors automatically (which I think could include non-unique username).
Warning: also a beginner... :)