Skip to content

Commit

Permalink
#209 big replace (screenName --> username)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonylampada committed Aug 28, 2014
1 parent 27ff12c commit 839b805
Show file tree
Hide file tree
Showing 63 changed files with 151 additions and 158 deletions.
2 changes: 1 addition & 1 deletion djangoproject/core/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ def process_exception(self, request, exception):
"""
user = request.user
if user.is_authenticated():
request.META['USER'] = "%s / %s" % (request.user.id, request.user.getUserInfo().screenName)
request.META['USER'] = "%s / %s" % (request.user.id, request.user.username)
else:
request.META['USER'] = "Unauthenticated"
15 changes: 8 additions & 7 deletions djangoproject/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ def get_website_short(self):
return self.website

def get_view_link(self):
kwargs = {'user_id': self.user.id}
if self.screenName:
kwargs['user_slug'] = urlquote(slugify(self.screenName))
return reverse('core.views.user_views.viewUser', kwargs=kwargs)
# kwargs = {'user_id': self.user.id}
# if self.screenName:
# kwargs['user_slug'] = urlquote(slugify(self.screenName))
return '/user/%s' % self.user.username
# return reverse('core.views.user_views.viewUser', kwargs=kwargs)

def is_complete(self):
return self.screenName and self.realName and self.user.email
return self.user.username and self.user.email


def gravatar_url_small(self):
Expand Down Expand Up @@ -990,7 +991,7 @@ def to_dict_json(self):
'programmer_id': self.programmer.id,
'programmer_link': self.programmer.get_view_link(),
'programmer_image': self.programmer.gravatar_url_medium(),
'programmer_screenname': self.programmer.getUserInfo().screenName,
'programmer_username': self.programmer.username,
'solution_id': self.solution.id,
'price': float(str(self.price)) if self.price else None,
}
Expand Down Expand Up @@ -1050,7 +1051,7 @@ def to_dict_json(self):
'entity': self.entity,
# 'creationDate': self.id,
'user_image': self.user.gravatar_url_medium(),
'user_screenname': self.user.getUserInfo().screenName,
'username': self.user.username,
'user_link': self.user.get_view_link(),
'user_id': self.user.id,
'project_id': self.project.id if self.project else None,
Expand Down
4 changes: 2 additions & 2 deletions djangoproject/core/services/bitcoin_frespo_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _log_info_active_send_confirmation(part):
part.id,
part.money_sent.value,
part.money_sent.to_address,
part.solution.programmer.getUserInfo().screenName,
part.solution.programmer.username,
part.payment.offer.issue.title)
logger.info(msg)

Expand All @@ -247,7 +247,7 @@ def _log_info_money_sent(part):
msg = 'MoneySent_%s %s bitcoins to programmer %s on address %s' % (
part.money_sent.id,
part.money_sent.value,
part.solution.programmer.getUserInfo().screenName,
part.solution.programmer.username,
part.money_sent.to_address)
logger.info(msg)

Expand Down
2 changes: 1 addition & 1 deletion djangoproject/core/services/issue_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def to_card_dict(issues):
for offer in issue.getOffers()[0:4]:
sponsor = {
'image_link': offer.sponsor.gravatar_url_medium(),
'screen_name': offer.sponsor.getUserInfo().screenName,
'username': offer.sponsor.username,
'sponsor_link': offer.sponsor.get_view_link(),
}
four_sponsors.append(sponsor)
Expand Down
42 changes: 22 additions & 20 deletions djangoproject/core/services/mail_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def send_func(watch):
if watch.user.id != solution.programmer.id:
_send_mail_to_user(
user=watch.user,
subject=solution.programmer.getUserInfo().screenName+" has just begun working on issue [%s]" % solution.issue.title,
subject=solution.programmer.username+" has just begun working on issue [%s]" % solution.issue.title,
templateName='email/workbegun.html',
contextData={"solution": solution,
"you": watch.user,
Expand All @@ -78,7 +78,7 @@ def notifyWatchers_project_edited(user, project, old_json, watches):
def send_func(watch):
if watch.user.id != user.id:
_send_mail_to_user(user=watch.user,
subject=user.getUserInfo().screenName + " edited project [%s]" % project.name,
subject=user.username + " edited project [%s]" % project.name,
templateName='email/project_edited.html',
contextData={"project": project,
"user": user,
Expand All @@ -95,7 +95,7 @@ def notifyWatchers_project_tag_added(user, project, tag, watches):
def send_func(watch):
if watch.user.id != user.id:
_send_mail_to_user(user=watch.user,
subject=user.getUserInfo().screenName + " added the tag [%s] to project [%s]" % (tag, project.name),
subject=user.username + " added the tag [%s] to project [%s]" % (tag, project.name),
templateName='email/project_tag_added.html',
contextData={"project": project,
"user": user,
Expand All @@ -111,7 +111,7 @@ def notifyWatchers_project_tag_removed(user, project, tag, watches):
def send_func(watch):
if watch.user.id != user.id:
_send_mail_to_user(user=watch.user,
subject=user.getUserInfo().screenName + " removed tag [%s] from project [%s]" % (tag, project.name),
subject=user.username + " removed tag [%s] from project [%s]" % (tag, project.name),
templateName='email/project_tag_removed.html',
contextData={"project": project,
"user": user,
Expand All @@ -127,7 +127,7 @@ def notifyWatchers_acceptingpayments(solution, watches):
def send_func(watch):
if(watch.user.id != solution.programmer.id):
_send_mail_to_user(user = watch.user,
subject = solution.programmer.getUserInfo().screenName+" is ready to accept payments for issue [%s]"%solution.issue.title,
subject = solution.programmer.username+" is ready to accept payments for issue [%s]"%solution.issue.title,
templateName = 'email/acceptingpayments.html',
contextData = {"solution" : solution,
"you" : watch.user,
Expand Down Expand Up @@ -161,7 +161,7 @@ def notifyWatchers_workstopped(solution, comment, watches):
def send_func(watch):
if(watch.user.id != solution.programmer.id):
_send_mail_to_user(user = watch.user,
subject = solution.programmer.getUserInfo().screenName+" has stopped working on issue [%s]"%solution.issue.title,
subject = solution.programmer.username+" has stopped working on issue [%s]"%solution.issue.title,
templateName = 'email/workstopped.html',
contextData = {"solution" : solution,
"you" : watch.user,
Expand All @@ -175,7 +175,7 @@ def notifyWatchers_workdone(solution, comment, watches):
def send_func(watch):
if(watch.user.id != solution.programmer.id):
_send_mail_to_user(user = watch.user,
subject = solution.programmer.getUserInfo().screenName+" resolved issue [%s]"%solution.issue.title,
subject = solution.programmer.username+" resolved issue [%s]"%solution.issue.title,
templateName = 'email/workdone.html',
contextData = {"theirSolution" : solution,
"you" : watch.user,
Expand All @@ -193,7 +193,7 @@ def send_func(watch):
if(watch.user.id != offer.sponsor.id):
_send_mail_to_user(user = watch.user,
subject = "%s revoked his %s %s offer for issue [%s]" % (
offer.sponsor.getUserInfo().screenName,
offer.sponsor.username,
offer.get_currency_symbol(),
str(twoplaces(offer.price)),
offer.issue.title
Expand All @@ -212,7 +212,7 @@ def send_func(watch):
if(watch.user.id != offer.sponsor.id):
_send_mail_to_user(user = watch.user,
subject = "%s made a %s %s offer for issue [%s]" % (
offer.sponsor.getUserInfo().screenName,
offer.sponsor.username,
offer.get_currency_symbol(),
str(offer.price),
offer.issue.title
Expand All @@ -237,15 +237,17 @@ def notifyWatchers_offerchanged(old_offer, new_offer, watches):
if(action):
def send_func(watch):
if(watch.user.id != new_offer.sponsor.id):
_send_mail_to_user(user = watch.user,
subject = old_offer.sponsor.getUserInfo().screenName+" "+action+" the "+old_offer.get_currency_symbol()+" "+str(twoplaces(old_offer.price))+" offer on issue [%s]"%old_offer.issue.title,
_send_mail_to_user(
user = watch.user,
subject = old_offer.sponsor.username+" "+action+" the "+old_offer.get_currency_symbol()+" "+str(twoplaces(old_offer.price))+" offer on issue [%s]"%old_offer.issue.title,
templateName = 'email/offerchanged.html',
contextData = {"you" : watch.user,
"old_offer" : old_offer,
"new_offer" : new_offer,
"action" : action,
"SITE_HOME" : settings.SITE_HOME},
whentrue='receiveEmail_issue_offer')
"old_offer": old_offer,
"new_offer": new_offer,
"action": action,
"SITE_HOME": settings.SITE_HOME},
whentrue='receiveEmail_issue_offer'
)
_notify_watchers(send_func, watches)


Expand All @@ -254,7 +256,7 @@ def notify_payment_parties_and_watchers_paymentconfirmed(payment, watches):
for part in payment.getParts():
_send_mail_to_user(
user = part.programmer,
subject=payment.offer.sponsor.getUserInfo().screenName+" has made you a "+payment.get_currency_symbol()+" "+str(twoplaces(part.price))+" payment",
subject=payment.offer.sponsor.username+" has made you a "+payment.get_currency_symbol()+" "+str(twoplaces(part.price))+" payment",
templateName='email/payment_received.html',
contextData={"payment" : payment,
"part" : part,
Expand All @@ -274,7 +276,7 @@ def notify_payment_parties_and_watchers_paymentconfirmed(payment, watches):
already_sent_to[payment.offer.sponsor.email] = True
def send_func(watch):
subject = "%s has paid his offer [%s %s / %s]" % (
payment.offer.sponsor.getUserInfo().screenName,
payment.offer.sponsor.username,
payment.offer.get_currency_symbol(),
str(twoplaces(payment.offer.price)),
payment.offer.issue.title)
Expand All @@ -293,7 +295,7 @@ def send_func(watch):
def notifyWatchers_newissuecomment(comment, watches):
def send_func(watch):
if(watch.user.id != comment.author.id):
subject = "%s added a comment on issue [%s]"%(comment.author.getUserInfo().screenName, comment.issue.title)
subject = "%s added a comment on issue [%s]"%(comment.author.username, comment.issue.title)
contextData = {"you" : watch.user,
"issue" : comment.issue,
"comment" : comment,
Expand All @@ -311,7 +313,7 @@ def notifyWatchers_newoffercomment(comment, watches):
def send_func(watch):
if watch.user.id != comment.author.id:
subject = "%s added a comment on offer [%s %s / %s]" % (
comment.author.getUserInfo().screenName,
comment.author.username,
comment.offer.get_currency_symbol(),
str(twoplaces(comment.offer.price)),
comment.offer.issue.title)
Expand Down
10 changes: 5 additions & 5 deletions djangoproject/core/services/stats_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

SELECT_SPONSORS = """
select
ui.user_id,
ui."screenName",
u.id,
u.username,
count(o.id) cOffer,
sum(case when (o.status = 'PAID' and o.currency = 'USD') then o.price else 0 end) spaidUSD,
sum(case when (o.status = 'OPEN' and (o."expirationDate" is null or o."expirationDate" > now()) and o.currency = 'USD') then o.price else 0 end) sopenUSD,
sum(case when (o.status = 'PAID' and o.currency = 'BTC') then o.price else 0 end) spaidBTC,
sum(case when (o.status = 'OPEN' and (o."expirationDate" is null or o."expirationDate" > now()) and o.currency = 'BTC') then o.price else 0 end) sopenBTC
from core_userinfo ui, core_offer o
from auth_user u, core_offer o
where
o.sponsor_id = ui.user_id
group by ui.user_id, ui."screenName"
o.sponsor_id = u.id
group by u.id, u.username
having sum(case when (o.status = 'PAID' and o.currency = 'USD') then o.price else 0 end) > 0
or sum(case when (o.status = 'OPEN' and (o."expirationDate" is null or o."expirationDate" > now()) and o.currency = 'USD') then o.price else 0 end) > 0
or sum(case when (o.status = 'PAID' and o.currency = 'BTC') then o.price else 0 end) > 0
Expand Down
12 changes: 3 additions & 9 deletions djangoproject/core/services/testmail_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@


SPONSOR = {
'getUserInfo': {
'screenName': 'Mr Sponsor'
}
'username': 'Mr Sponsor'
}


Expand All @@ -20,9 +18,7 @@
{
'solution': {
'programmer': {
'getUserInfo': {
'screenName': 'Programmer 1'
}
'username': 'Programmer 1'
},
},
'money_sent': {
Expand All @@ -33,9 +29,7 @@
{
'solution': {
'programmer': {
'getUserInfo': {
'screenName': 'Programmer 2'
}
'username': 'Programmer 2'
},
},
'money_sent': {
Expand Down
6 changes: 3 additions & 3 deletions djangoproject/core/services/user_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def getAlertsForViewUser(logged_user, user_to_view, changedPrimaryEmail, changed

def edit_existing_user(user, dict):
userinfo = user.getUserInfo()
userinfo.screenName = dict['screenName']
# userinfo.screenName = dict['screenName']
userinfo.website = dict['website']
userinfo.about = dict['about']
userinfo.realName = dict['realName']
Expand Down Expand Up @@ -66,8 +66,8 @@ def deactivate_user(user):
user.is_active = False
user.save()
mail_services.deactivated(user)
subject = 'user deactivated: %s/%s' % (user.id, user.getUserInfo().screenName)
body = '<a href="http://freedomsponsors.org/user/%s">%s</a>' % (user.id, user.getUserInfo().screenName)
subject = 'user deactivated: %s/%s' % (user.id, user.username)
body = '<a href="http://freedomsponsors.org/user/%s">%s</a>' % (user.id, user.username)
mail_services.notify_admin(subject, body)


Expand Down
3 changes: 0 additions & 3 deletions djangoproject/core/tests/helpers/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def createDummyUserRandom(login, password):
random_login = '%s_%s'%(login, randomnum)
user = User.objects.create_user(random_login, random_login+'@gogogo.com', password)
userinfo = UserInfo.newUserInfo(user)
userinfo.screenName = login+' Screen'
userinfo.realName = login+' Real'
userinfo.save()
return user
Expand All @@ -22,7 +21,6 @@ def create_dummy_sponsor():
randomnum = randint(0,100000)
user = User.objects.create_user('userone_%s'%randomnum, 'userone_%[email protected]'%randomnum, 'abcdef')
userinfo = UserInfo.newUserInfo(user)
userinfo.screenName = 'User One'
userinfo.realName = 'User One'
userinfo.save()
return user
Expand All @@ -31,7 +29,6 @@ def create_dummy_programmer():
randomnum = randint(0,100000)
user = User.objects.create_user('usertwo_%s'%randomnum, 'usertwo_%[email protected]'%randomnum, 'abcdef')
userinfo = UserInfo.newUserInfo(user)
userinfo.screenName = 'User Two'
userinfo.realName = 'User Two'
userinfo.save()
return user
Expand Down
2 changes: 1 addition & 1 deletion djangoproject/core/tests/test_bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class X:
bitcoin_frespo_services.bitcoin_active_send_confirmation()
email_asserts.assert_sent_count(self, 3)
email_asserts.assert_sent(self, to=programmer.email,
subject='%s has made you a BTC %s payment' % (offer.sponsor.getUserInfo().screenName, email_value1))
subject='%s has made you a BTC %s payment' % (offer.sponsor.username, email_value1))
email_asserts.assert_sent(self, to=offer.sponsor.email, subject='You have made a BTC %s payment' % email_value1)
email_asserts.assert_sent(self, to=settings.ADMINS[0][1], subject='Bitcoin payment made - %s' % email_value2)

Expand Down
Loading

0 comments on commit 839b805

Please sign in to comment.