<commit_before>import cgi
from google.appengine.ext import webapp
from model import *
from google.appengine.api import users
import registration as registration
import os
from google.appengine.ext.webapp import template
from mail_handler import *
from mail_sender import *
from serverUtils import UrlBuilder
from ajaxUtilities import alertMessage
from ajaxUtilities import redirectPage
from ajaxUtilities import authenticatedUser

class RegisterTransactionHandler(webapp.RequestHandler):
	
	def post(self):
		rejectPath = UrlBuilder(self.request).buildUrl('/reject')
		
		group = Group.get(self.request.get('group'))
		creator = users.get_current_user();
		fromUser = users.User(self.request.get('fromUser'))
		toUser = users.User(self.request.get('toUser'));
		try:
		  amount = float(self.request.get('amount'))
		except BaseException, e:
			error = 'Invalid amount: %s.' % self.request.get('amount')
			alertMessage(self, error)
			return
		
		reason = self.request.get('reason')
		type = self.request.get('type')
		
		if amount <= 0:
			error = 'Invalid amount: %s.' % amount
			alertMessage(self, error)
			return
		
		tr = Transaction(
			group = group,
			creator = creator, fromUser = fromUser, toUser = toUser,
			type = type,
			amount = amount, reason = reason,
			isRejected = False
			)
		tr.put()
				
		fromMembership = Membership.gql("WHERE user = :1 AND group = :2", fromUser, group).get()
		toMembership = Membership.gql("WHERE user = :1 AND group = :2", toUser, group).get()
		# TODO revisar
		if type == 'debt' or type == 'rejectedPayment':
			fromMembership.balance -= amount
			toMembership.balance += amount
			if(fromUser != creator):
				MailSender().sendTransactionNotice(fromUser.email(), fromMembership.name, tr, rejectPath)
		elif type == 'payment' or type == 'rejectedDebt': 
			fromMembership.balance += amount
			toMembership.balance -= amount
			if(toUser != creator):
				MailSender().sendTransactionNotice(toUser.email(), toMembership.name, tr, rejectPath)
				
		fromMembership.put()
		toMembership.put()<commit_msg>Corregido un bug donde se usaba .name en lugar de .name()<commit_after>import cgi
from google.appengine.ext import webapp
from model import *
from google.appengine.api import users
import registration as registration
import os
from google.appengine.ext.webapp import template
from mail_handler import *
from mail_sender import *
from serverUtils import UrlBuilder
from ajaxUtilities import alertMessage
from ajaxUtilities import redirectPage
from ajaxUtilities import authenticatedUser

class RegisterTransactionHandler(webapp.RequestHandler):
	
	def post(self):
		rejectPath = UrlBuilder(self.request).buildUrl('/reject')
		
		group = Group.get(self.request.get('group'))
		creator = users.get_current_user();
		fromUser = users.User(self.request.get('fromUser'))
		toUser = users.User(self.request.get('toUser'));
		try:
		  amount = float(self.request.get('amount'))
		except BaseException, e:
			error = 'Invalid amount: %s.' % self.request.get('amount')
			alertMessage(self, error)
			return
		
		reason = self.request.get('reason')
		type = self.request.get('type')
		
		if amount <= 0:
			error = 'Invalid amount: %s.' % amount
			alertMessage(self, error)
			return
		
		tr = Transaction(
			group = group,
			creator = creator, fromUser = fromUser, toUser = toUser,
			type = type,
			amount = amount, reason = reason,
			isRejected = False
			)
		tr.put()
				
		fromMembership = Membership.gql("WHERE user = :1 AND group = :2", fromUser, group).get()
		toMembership = Membership.gql("WHERE user = :1 AND group = :2", toUser, group).get()
		# TODO revisar
		if type == 'debt' or type == 'rejectedPayment':
			fromMembership.balance -= amount
			toMembership.balance += amount
			if(fromUser != creator):
				MailSender().sendTransactionNotice(fromUser.email(), fromMembership.name(), tr, rejectPath)
		elif type == 'payment' or type == 'rejectedDebt': 
			fromMembership.balance += amount
			toMembership.balance -= amount
			if(toUser != creator):
				MailSender().sendTransactionNotice(toUser.email(), toMembership.name(), tr, rejectPath)
				
		fromMembership.put()
		toMembership.put()
{'fraction_non_alphanumeric': 0.11897880539499037, 'fraction_numerical': 0.0024084778420038534, 'mean_word_length': 4.317541613316261, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '218064', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1230, 'n_words': 331}