Author: jtauber
Date: Sat Sep 27 06:17:05 2008
New Revision: 953

Modified:
    trunk/local_apps/account/forms.py
    trunk/local_apps/zwitschern/pownce_utils.py
    trunk/local_apps/zwitschern/utils.py

Log:
moved twitter and pownce over to using new other services model

Modified: trunk/local_apps/account/forms.py
==============================================================================
--- trunk/local_apps/account/forms.py   (original)
+++ trunk/local_apps/account/forms.py   Sat Sep 27 06:17:05 2008
@@ -236,34 +236,40 @@
          self.user.message_set.create(message=ugettext(u"Language  
successfully updated."))


-class TwitterForm(ProfileForm):
+# @@@ these should somehow be moved out of account or at least out of this  
module
+
+from account.models import OtherServiceInfo, other_service,  
update_other_services
+
+class TwitterForm(UserForm):
      username = forms.CharField(label=_("Username"), required=True)
      password = forms.CharField(label=_("Password"), required=True,
                                  
widget=forms.PasswordInput(render_value=False))

      def __init__(self, *args, **kwargs):
          super(TwitterForm, self).__init__(*args, **kwargs)
-        self.initial.update({"username": self.profile.twitter_user})
+        self.initial.update({"username":  
other_service(self.user, "twitter_user")})

      def save(self):
          from zwitschern.utils import get_twitter_password
-        self.profile.twitter_user = self.cleaned_data['username']
-        self.profile.twitter_password =  
get_twitter_password(settings.SECRET_KEY, self.cleaned_data['password'])
-        self.profile.save()
+        update_other_services(self.user,
+            twitter_user = self.cleaned_data['username'],
+            twitter_password = get_twitter_password(settings.SECRET_KEY,  
self.cleaned_data['password']),
+        )
          self.user.message_set.create(message=ugettext(u"Successfully  
authenticated."))

-class PownceForm(ProfileForm):
+class PownceForm(UserForm):
      usernamep = forms.CharField(label=_("Username"), required=True)
      passwordp = forms.CharField(label=_("Password"), required=True,
                                  
widget=forms.PasswordInput(render_value=False))

      def __init__(self, *args, **kwargs):
          super(PownceForm, self).__init__(*args, **kwargs)
-        self.initial.update({"usernamep": self.profile.pownce_user})
+        self.initial.update({"usernamep":  
other_service(self.user, "pownce_user")})

      def save(self):
          from zwitschern.pownce_utils import get_pownce_password
-        self.profile.pownce_user = self.cleaned_data['usernamep']
-        self.profile.pownce_password =  
get_pownce_password(settings.SECRET_KEY, self.cleaned_data['passwordp'])
-        self.profile.save()
-        self.user.message_set.create(message=ugettext(u"Successfully  
authenticated."))
\ No newline at end of file
+        update_other_service(self.user,
+            pownce_user = self.cleaned_data['usernamep'],
+            pownce_password = get_pownce_password(settings.SECRET_KEY,  
self.cleaned_data['passwordp']),
+        )
+        self.user.message_set.create(message=ugettext(u"Successfully  
authenticated."))

Modified: trunk/local_apps/zwitschern/pownce_utils.py
==============================================================================
--- trunk/local_apps/zwitschern/pownce_utils.py (original)
+++ trunk/local_apps/zwitschern/pownce_utils.py Sat Sep 27 06:17:05 2008
@@ -7,14 +7,19 @@

  from django.conf import settings

+from account.models import other_service
+
  def pownce_account_raw(username, password):
+    # @@@ what is this hard coded key doing here!?!
      return pownce.Api(username,  
password, 'li6yw8q8ivv8ga9zda28iio4z652377y')

  def pownce_account_for_user(user):
-    profile = user.get_profile()
-    if profile.pownce_user and profile.pownce_password:
-        pownce_password =  
get_pownce_password(settings.SECRET_KEY,profile.pownce_password,  
decode=True)
-        return pownce_account_raw(profile.pownce_user, pownce_password)
+    pownce_user = other_service(user, "pownce_user")
+    pownce_password = other_service(user, "pownce_password")
+
+    if pownce_user and pownce_password:
+        pownce_password = get_pownce_password(settings.SECRET_KEY,  
pownce_password, decode=True)
+        return pownce_account_raw(pownce_user, pownce_password)

  def pownce_verify_credentials(account):
      try:

Modified: trunk/local_apps/zwitschern/utils.py
==============================================================================
--- trunk/local_apps/zwitschern/utils.py        (original)
+++ trunk/local_apps/zwitschern/utils.py        Sat Sep 27 06:17:05 2008
@@ -9,14 +9,18 @@

  from django.conf import settings

+from account.models import other_service
+
  def twitter_account_raw(username, password):
      return twitter.Api(username=username, password=password)

  def twitter_account_for_user(user):
      profile = user.get_profile()
-    if profile.twitter_user and profile.twitter_password:
-        twitter_password = get_twitter_password(settings.SECRET_KEY,  
profile.twitter_password, decode=True)
-        return twitter_account_raw(profile.twitter_user, twitter_password)
+    twitter_user = other_service(user, "twitter_user")
+    twitter_password = other_service(user, "twitter_password")
+    if twitter_user and twitter_password:
+        twitter_password = get_twitter_password(settings.SECRET_KEY,  
twitter_password, decode=True)
+        return twitter_account_raw(twitter_user, twitter_password)

  def twitter_verify_credentials(account):
      if account is None:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to