Guillermo Szeliga avatar Guillermo Szeliga committed 155e725 Draft

- Accounts management: prompt account field values done.

Comments (0)

Files changed (4)

api/shelf/console/shell.py

 		operation_parts = operation.rsplit(" ")
 
 		if operation_parts[0] == 'create':
-			descriptor = account_manager.get_configuration_descriptor()
-
-			print 'descriptor: ' + descriptor
+			account_fields_descriptor = account_manager.get_configuration_descriptor()
 
 			#1- Asks for all values
-			values = {}
+			field_values = {}
+
+			for field in account_fields_descriptor:
+				value=raw_input(field.label() + ": ")
+
+				field_values[field.name()]=value
+
+
+			print field_values
 
 			#2- Creates new account data
-			account_data = account_manager.create(values)
+			account_data = account_manager.create(field_values)
 
 			#3- If account needs authorization
 			account_data = account_manager.authorize(account_data)

api/storages/adapters/box/adapter.py

 		if "OAuthTokenSecret" in parsed_data:
 			self._oauth_token_secret = parsed_data["OAuthTokenSecret"]
 
-	@skeleton.account_field('box','appKey')
+	@skeleton.account_field('box','appKey', 'Application key', skeleton.AccountFieldDescriptor.FIELD_TYPE_STRING)
 	def appKey(self):
 		return self._appKey
 
 		self._oauth_token = access_token.key
 		self._oauth_token_secret = access_token.secret
 
-	@skeleton.account_field('box','OAuthToken')
+	@skeleton.account_field('box','OAuthToken', 'OAuth application token', skeleton.AccountFieldDescriptor.FIELD_TYPE_STRING)
 	def oauthToken(self):
 		return self._oauth_token
 
 		return self._oauth_token_secret
 
 	def isAccessGranted(self):
-		return (self._oauth_token_secret != None and self._oauth_token != None)
+		return self._oauth_token_secret is not None and self._oauth_token is not None
 
 	@staticmethod
 	def get_configuration_fields():

api/storages/adapters/dropbox/adapter.py

 		self._oauth_token = access_token.key
 		self._oauth_token_secret = access_token.secret
 
-	@skeleton.account_field('dropbox','appKey')
+	@skeleton.account_field('dropbox','appKey', 'Application key', skeleton.AccountFieldDescriptor.FIELD_TYPE_STRING)
 	def appKey(self):
 		return self._appKey
 
 		return self._oauth_token_secret
 
 	def isAccessGranted(self):
-		return (self._oauth_token_secret != None and self._oauth_token != None)
+		return self._oauth_token_secret is not None and self._oauth_token is not None
 
 	def jsonize(self):
 		return dict({'appKey': self._appKey, 'appSecret': self._appSecret, 'accessType': self._accessType, 'OAuthToken' : self._oauth_token, 'OAuthTokenSecret': self._oauth_token_secret})

api/storages/adapters/skeleton.py

 
 __accounts_field_registry__ = {}
 
-def account_field(cls,name):
+def account_field(cls,name, label, type):
 
 	def inner(f):
 
-		__accounts_field_registry__[cls]=name
+		if cls in __accounts_field_registry__:
+			__accounts_field_registry__[cls].append(AccountFieldDescriptor(name, label,type))
+		else:
+			__accounts_field_registry__[cls]=[AccountFieldDescriptor(name, label,type)]
 
 		def wrapped(*args, **kwargs):
 			return f(*args, **kwargs)
 		pass
 
 
-
 class StorageAccountData(json_types.JSonizable):
 
 	def __init__(self):
 	@staticmethod
 	@abc.abstractmethod
 	def create_descriptor(properties=None,interactive=False):
-		pass
+		pass
+
+class AccountFieldDescriptor():
+
+	FIELD_TYPE_STRING=1
+
+	def __init__(self,name,label=None,type=FIELD_TYPE_STRING):
+		self.__name=name
+		self.__type=type
+		self.__label=label
+
+	def name(self):
+		return self.__name
+
+	def label(self):
+		if self.__label is None:
+			return self.__name
+
+		return self.__label
+
+	def type(self):
+		return self.__type
+
+	def __str__(self):
+		return '{name: %s, label: %s, type: %i}'% (self.name(), self.label(),self.type())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.