Skip to content

Commit

Permalink
fixes on path split and check if email exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Zuccarini committed Jan 2, 2020
1 parent 2adcf14 commit 6c93b0b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 65 deletions.
39 changes: 19 additions & 20 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,27 +1041,26 @@ def tax_report(to_emails=None, zip_paths=None, tax_year=None):
if tax_year is None:
# retrieve last year
tax_year = datetime.date.today().year-1

for idx, to_email in enumerate(to_emails):
cur_language = translation.get_language()
try:
setup_lang(to_email)
subject = f"Your tax report for year ({tax_year})"
html, text = render_tax_report(to_email, tax_year)
from_email = settings.CONTACT_EMAIL
send_mail(
from_email,
to_email,
subject,
text,
html,
from_name="Kevin Owocki (Gitcoin.co)",
categories=['marketing', func_name()],
zip_path=zip_paths[idx]
)

finally:
translation.activate(cur_language)
if to_email:
cur_language = translation.get_language()
try:
setup_lang(to_email)
subject = f"Your tax report for year ({tax_year})"
html, text = render_tax_report(to_email, tax_year)
from_email = settings.CONTACT_EMAIL
send_mail(
from_email,
to_email,
subject,
text,
html,
from_name="Kevin Owocki (Gitcoin.co)",
categories=['marketing', func_name()],
zip_path=zip_paths[idx]
)
finally:
translation.activate(cur_language)


def bounty_expire_warning(bounty, to_emails=None):
Expand Down
4 changes: 2 additions & 2 deletions app/marketing/management/commands/send_tax_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def zip_dir(username, username_path):
if filename.endswith('.zip'):
continue
abs_path = os.path.join(root, filename)
zipf.write(abs_path, abs_path.split('code/tax_report')[1])
zipf.write(abs_path, abs_path.split('tax_report')[1])
zipf.close()
return zip_file_path

Expand Down Expand Up @@ -324,7 +324,7 @@ def handle(self, *args, **options):
TOKEN_NAME,
USD_VALUE,
WORKER_TYPE]
csv_file_path = os.path.join(username_path, p.username + '_tax_report.csv')
csv_file_path = os.path.join(username_path, p.username + '_report.csv')
try:
with open(csv_file_path, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
Expand Down
44 changes: 1 addition & 43 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,49 +781,7 @@ def tax_settings(request):
address = profile.address
else:
address = ''

if request.POST:

if 'preferred_payout_address' in request.POST.keys():
profile.preferred_payout_address = request.POST.get('preferred_payout_address', '')
profile.save()
msg = _('Updated your Address')
elif request.POST.get('disconnect', False):
profile.github_access_token = ''
profile = record_form_submission(request, profile, 'account-disconnect')
profile.email = ''
profile.save()
create_user_action(profile.user, 'account_disconnected', request)
messages.success(request, _('Your account has been disconnected from Github'))
logout_redirect = redirect(reverse('logout') + '?next=/')
return logout_redirect
elif request.POST.get('delete', False):

# remove profile
profile.hide_profile = True
profile = record_form_submission(request, profile, 'account-delete')
profile.email = ''
profile.save()

# remove email
delete_user_from_mailchimp(es.email)

if es:
es.delete()
request.user.delete()
AccountDeletionRequest.objects.create(
handle=profile.handle,
profile={
'ip': get_ip(request),
}
)
profile.delete()
messages.success(request, _('Your account has been deleted.'))
logout_redirect = redirect(reverse('logout') + '?next=/')
return logout_redirect
else:
msg = _('Error: did not understand your request')


context = {
'is_logged_in': is_logged_in,
'nav': 'home',
Expand Down

0 comments on commit 6c93b0b

Please sign in to comment.