Coder Social home page Coder Social logo

django-friends's Introduction

django-friends's People

Contributors

alibrahim avatar brosner avatar empty avatar jezdez avatar jtauber avatar tmc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-friends's Issues

Notify people when their contacts sign up

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)

add JoinInvitation.accepted_by

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

Invitations shouldnt show "Accepted" invitations

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?

InviteFriendForm cleaned_data error

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

Google import does not work with gdata 1.2.4

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()

'ContentType' object has no attribute 'verified'

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'

AttributeError: 'Permission' 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.

Adding a decline() method to FriendshipInvitation

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 %}

Missing License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.