]> git.openstreetmap.org Git - osqa.git/commitdiff
OSQA-605, store user logins in a separate action, this helps to easily retrieve the...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 2 Aug 2011 12:11:29 +0000 (12:11 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 2 Aug 2011 12:11:29 +0000 (12:11 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1148 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/user.py
forum/views/auth.py
forum_modules/facebookauth/authentication.py

index 15ad5ee9e3218e8d603d9ced57fd012e0e1a4f06..3366a6cf360fc212ff4401e541f499ef332d6219 100644 (file)
@@ -23,6 +23,15 @@ class UserJoinsAction(ActionProxy):
         'app_name': APP_SHORT_NAME,
         }
 
+class UserLoginAction(ActionProxy):
+    verb = _("logged in")
+
+    def describe(self, viewer=None):
+        return _("%(user)s %(have_has)s logged in") % {
+            'user' : self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+            'have_has': self.viewer_or_user_verb(viewer, self.user, _('have'), _('has')),
+        }
+
 class EmailValidationAction(ActionProxy):
     verb = _("validated e-mail")
 
index c64aa1d513428d387a20cf61090cd3160a934bb5..1b18d6c08ee459315430155677af0ed7d617da87 100644 (file)
@@ -23,7 +23,7 @@ from forum.utils.mail import send_template_email
 from forum.authentication.base import InvalidAuthentication
 from forum.authentication import AUTH_PROVIDERS
 from forum.models import User, AuthKeyUserAssociation, ValidationHash
-from forum.actions import UserJoinsAction
+from forum.actions import UserJoinsAction, UserLoginAction
 from forum import settings
 
 from vars import ON_SIGNIN_SESSION_ATTR, PENDING_SUBMISSION_SESSION_ATTR
@@ -374,6 +374,9 @@ def login_and_forward(request, user, forward=None, message=None):
     user.backend = "django.contrib.auth.backends.ModelBackend"
     login(request, user)
 
+    # Store the login action
+    UserLoginAction(user=user, ip=request.META['REMOTE_ADDR']).save()
+
     if message is None:
         message = _("Welcome back %s, you are now logged in") % smart_unicode(user.username)
 
index aa54c42ece8d9e4e4e7f916c4594e8688ea4435a..4e9a44ac3255db9086393cf037806a9278bcd10a 100644 (file)
@@ -82,6 +82,6 @@ class FacebookAuthContext(ConsumerTemplateContext):
     weight = 100
     human_name = 'Facebook'
     code_template = 'modules/facebookauth/button.html'
-    extra_css = ["http://www.facebook.com/css/connect/connect_button.css"]
+    extra_css = []
 
     API_KEY = settings.FB_API_KEY
\ No newline at end of file