Note that work is no longer happening directly on this repo.
Much of it is being replaced by things such as:
friendship, contact and invitation management for the Django web framework
Note that work is no longer happening directly on this repo.
Much of it is being replaced by things such as:
http://code.google.com/p/django-friends/issues/detail?id=7
It's a new feature. Do the same as Gmail or Yahoo to be able to import
Hotmail contacts
The patch follows. What is left is to create the notification template.
diff --git a/friends/management.py b/friends/management.py index 387a69c..76e8241 100644 --- a/friends/management.py +++ b/friends/management.py @@ -7,6 +7,7 @@ if "notification" in settings.INSTALLED_APPS: from notification import models as notification def create_notice_types(app, created_models, verbosity, **kwargs): + notification.create_notice_type("contact_joined", _("Contact Joined"), _("one of your contacts has joined the site"), default=2) notification.create_notice_type("friends_invite", _("Invitation Received"), _("you have received an invitation"), default=2) notification.create_notice_type("friends_invite_sent", _("Invitation Sent"), _("you have sent an invitation"), default=1) notification.create_notice_type("friends_accept", _("Acceptance Received"), _("an invitation you sent has been accepted"), default=2) diff --git a/friends/models.py b/friends/models.py index 03afcd5..9ebcc9b 100644 --- a/friends/models.py +++ b/friends/models.py @@ -226,8 +226,10 @@ if EmailAddress: join_invitation.save() # notification will be covered below for contact in Contact.objects.filter(email=instance.email): - contact.users.add(instance.user) - # @@@ send notification + if not instance.user in contact.users.all(): + contact.users.add(instance.user) + if notification: + notification.send([contact.user], "contact_joined", {"new_user": instance.user}) # only if django-email-notification is installed signals.post_save.connect(new_user, sender=EmailAddress)
when a join invitation is accepted it would be nice to have an easier way to see which user accepted the invitation.
class JoinInvitation(models.Model): ... accepted_by = models.ForeignKey(User, related_name="invited_via", blank=True, null=True) def accept(self): ... self.accepted_by = new_user
http://code.google.com/p/django-friends/issues/detail?id=8
The attached patch will add a module for status choices, so we don't have
to remember which number is related to a status while building custom views.CREATED = '1'
SENT = '2'
FAILED = '3'
EXPIRED = '4'
ACCEPTED = '5'
DECLINED = '6'
JOINED = '7'
class FriendshipInvitationManager(models.Manager):
def invitations(self, *args, **kwargs):
return self.filter(*args, **kwargs).exclude(status__in=["6", "8"])
Should be:
class FriendshipInvitationManager(models.Manager):
def invitations(self, *args, **kwargs):
return self.filter(*args, **kwargs).exclude(status__in=["5", "6", "8"])
Unless Im misunderstanding something?
Because the Invitation status is defined as a char in model but referrred to as int in code the expression:
if join_invitation.status not in [5, 7](line 183 in models.py)
always evaluates to true if you are running postgresql as chars are not integers.
I suggest changing the status field to an integer.
When trying to use the InviteFriendForm in such a way:
form = InviteFriendForm(user=request.user)
form.initial['to_user'] = "peter"
form = form.clean()
if form.is_valid():
...
I get the error:
'InviteFriendForm' object has no attribute 'cleaned_data'
If I'm just approaching this from a silly angle, could you please let me know the proper way to use the InviteFriendForm.
Also, usage examples or an overview on the wiki would be very helpful.
thanks
The patch follows.
diff --git a/friends/importer.py b/friends/importer.py index fdb52a6..1958a8b 100644 --- a/friends/importer.py +++ b/friends/importer.py @@ -87,7 +87,7 @@ def import_google(authsub_token, user): """ contacts_service = gdata.contacts.service.ContactsService() - contacts_service.auth_token = authsub_token + contacts_service.SetAuthSubToken(authsub_token) contacts_service.UpgradeToSessionToken() entries = [] feed = contacts_service.GetContactsFeed()
I created a Danish locale file located here:
http://code.google.com/p/django-friends/issues/detail?id=3
Currently, the Friendship model doesn't check to see if from_user is the
same as to_user when saving. This allows the creation of friendships with
oneself.To fix it, I've added a custom save() method:
def save(self): if self.to_user == self.from_user: return else: super(Friendship, self).save()
When trying to install django-friends for the first time, I get this error while running syncdb:
Traceback (most recent call last):
File "C:\dev\myfirsties\manage.py", line 11, in <module>
execute_manager(settings)
File "C:\dev\django\core\management\__init__.py", line 362, in execute_manager
utility.execute()
File "C:\dev\django\core\management\__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\dev\django\core\management\base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\dev\django\core\management\base.py", line 222, in execute
output = self.handle(*args, **options)
File "C:\dev\django\core\management\base.py", line 351, in handle
return self.handle_noargs(**options)
File "C:\dev\django\core\management\commands\syncdb.py", line 99, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive)
File "C:\dev\django\core\management\sql.py", line 205, in emit_post_sync_signal
interactive=interactive)
File "C:\dev\django\dispatch\dispatcher.py", line 166, in send
response = receiver(signal=self, sender=sender, **named)
File "C:\dev\django\contrib\auth\management\__init__.py", line 25, in create_permissions
ctype = ContentType.objects.get_for_model(klass)
File "C:\dev\django\contrib\contenttypes\models.py", line 31, in get_for_model
defaults = {'name': smart_unicode(opts.verbose_name_raw)},
File "C:\dev\django\db\models\manager.py", line 123, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "C:\dev\django\db\models\query.py", line 335, in get_or_create
obj.save(force_insert=True)
File "C:\dev\django\db\models\base.py", line 410, in save
self.save_base(force_insert=force_insert, force_update=force_update)
File "C:\dev\django\db\models\base.py", line 506, in save_base
created=(not record_exists), raw=raw)
File "C:\dev\django\dispatch\dispatcher.py", line 166, in send
response = receiver(signal=self, sender=sender, **named)
File "C:\dev\friends\models.py", line 208, in new_user
if instance.verified:
AttributeError: 'ContentType' object has no attribute 'verified'
I was getting "AttributeError: 'Permission' object has no attribute 'verified'" when running syncdb.
I removed lines 206-216 from models.py:
# @@@ this assumes email-confirmation is being used
def new_user(sender, instance, **kwargs):
if instance.verified:
for join_invitation in JoinInvitation.objects.filter(contact__email=instance.email):
if join_invitation.status not in ["5", "7"]: # if not accepted or already marked as joined independently
join_invitation.status = "7"
join_invitation.save()
# notification will be covered below
for contact in Contact.objects.filter(email=instance.email):
contact.users.add(instance.user)
# @@@ send notification
Once I removed them syncdb worked.
http://code.google.com/p/django-friends/issues/detail?id=5
diff -urN --exclude=.svn --exclude='*pyc' friends/management.py
friends.new/management.py
--- friends/management.py 2008-08-11 03:16:15.000000000 +0300
+++ friends.new/management.py 2008-08-11 03:15:22.000000000 +0300
@@ -10,6 +10,8 @@
notification.create_notice_type("friends_invite_sent",
_("Invitation Sent"), _("you have sent an invitation"), default=1)
notification.create_notice_type("friends_accept", _("Acceptance
Received"), _("an invitation you sent has been accepted"), default=2)
notification.create_notice_type("friends_accept_sent",
_("Acceptance Sent"), _("you have accepted an invitation you received"),
default=1)
+ notification.create_notice_type("friends_decline", _("Declination
Received"), _("an invitation you sent has been declined", default=2)
+ notification.create_notice_type("friends_decline_sent",
_("Declination Sent"), _("you have declined an invitation you received"),
default=1)
notification.create_notice_type("friends_otherconnect", _("Other
Connection"), _("one of your friends has a new connection"), default=2)
notification.create_notice_type("join_accept", _("Join Invitation
Accepted"), _("an invitation you sent to join this site has been
accepted"), default=2)
diff -urN --exclude=.svn --exclude='*pyc' friends/models.py
friends.new/models.py
--- friends/models.py 2008-08-11 03:16:15.000000000 +0300
+++ friends.new/models.py 2008-08-11 03:15:38.000000000 +0300
@@ -172,6 +172,14 @@
if user != self.to_user and user != self.from_user:
notification.send([user], "friends_otherconnect",
{"invitation": self, "to_user": self.to_user})
+ def decline(self):
+ self.status = 6
+ self.save()
+ if notification:
+ notification.send([self.from_user], "friends_decline",
{"invitation":self})
+ notification.send([self.to_user], "friends_decline_sent",
{"invitation":self})
+
+
# @@@ this assumes email-confirmation is being used
def new_user(sender, instance, **kwargs):
if instance.verified:
diff -urN --exclude=.svn --exclude='*pyc'
friends/templates/notification/friends_decline/plain.txt
friends.new/templates/notification/friends_decline/plain.txt
--- friends/templates/notification/friends_decline/plain.txt 1970-01-01
02:00:00.000000000 +0200
+++ friends.new/templates/notification/friends_decline/plain.txt 2008-08-11
03:20:03.000000000 +0300
@@ -0,0 +1 @@
+{% load i18n %}{% blocktrans with invitation.to_user as invitation_to_user
%}{{ invitation_to_user }} has declined your friend request.{% endblocktrans %}
diff -urN --exclude=.svn --exclude='*pyc'
friends/templates/notification/friends_decline/teaser.html
friends.new/templates/notification/friends_decline/teaser.html
--- friends/templates/notification/friends_decline/teaser.html 1970-01-01
02:00:00.000000000 +0200
+++ friends.new/templates/notification/friends_decline/teaser.html
2008-08-11 03:20:20.000000000 +0300
@@ -0,0 +1,2 @@
+{% load i18n captureas_tag %}{% captureas user_url %}{% url profile_detail
username=invitation.to_user.username %}{% endcaptureas %}
+{% blocktrans with invitation.to_user as invitation_user %}{{
invitation_user }} has declined your friend request.{% endblocktrans %}
diff -urN --exclude=.svn --exclude='*pyc'
friends/templates/notification/friends_decline_sent/plain.txt
friends.new/templates/notification/friends_decline_sent/plain.txt
--- friends/templates/notification/friends_decline_sent/plain.txt
1970-01-01 02:00:00.000000000 +0200
+++ friends.new/templates/notification/friends_decline_sent/plain.txt
2008-08-11 03:20:37.000000000 +0300
@@ -0,0 +1 @@
+{% load i18n %}{% blocktrans with invitation.from_user as
invitation_from_user %}You declined {{ invitation_from_user }}'s friend
request.{% endblocktrans %}
diff -urN --exclude=.svn --exclude='*pyc'
friends/templates/notification/friends_decline_sent/teaser.html
friends.new/templates/notification/friends_decline_sent/teaser.html
--- friends/templates/notification/friends_decline_sent/teaser.html
1970-01-01 02:00:00.000000000 +0200
+++ friends.new/templates/notification/friends_decline_sent/teaser.html
2008-08-11 03:20:53.000000000 +0300
@@ -0,0 +1,2 @@
+{% load i18n captureas_tag %}{% captureas user_url %}{% url profile_detail
username=invitation.from_user.username %}{% endcaptureas %}
+{% blocktrans with invitation.from_user as invitation_from_user %}You
declined <a href="{{ user_url }}">{{ invitation_from_user }}</a>'s friend
request.{% endblocktrans %}
ybrowserauth is a one-off sample script not subject to revision control, releases, etc. Yahoo's python social sdk supports OAuth and seems like a much better alternative to me:
There's no license included in this app. Presumably it's hosted here on Github for others to use and contribute to, but we can't make that asssumption without a license.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.