Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a decline() method to FriendshipInvitation #3

Open
zerok opened this issue May 7, 2009 · 1 comment
Open

Adding a decline() method to FriendshipInvitation #3

zerok opened this issue May 7, 2009 · 1 comment

Comments

@zerok
Copy link

zerok commented May 7, 2009

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 %}
@zerok
Copy link
Author

zerok commented May 7, 2009

http://code.google.com/p/django-friends/issues/detail?id=5

brosner:

Please don't paste your diff right in the issue description. It makes it nearly impossible to read. Please either
attach it or paste it a pastebin such as dpaste.com.

However, from what I can read, sending a notification on decline is not likely to be something sites will want. I
would encourage that to be a setting that is off by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant