Repository: fossasia/open-event-server

Issue:
Make discount/promotional code case-insensitive
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Users get invalid discount/promotional code error because it is currently case-sensitive.

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
It will be a better user experience if we make the discount/promotional code case-insensitive.

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->



Discussion:
@dhsgisc are you working on this? I would like to take this up
pls be my guest mr @shreyanshdwivedi :)
@Anupam-dagar I already made the changes on my local but couldn't make a PR due to my busy schedule. 
@shreyanshdwivedi is it okay if I keep my PR open? I missed out on the claim part here.
@Anupam-dagar it's ok. Please take care for next time
@shreyanshdwivedi  sure :tada: 
@Anupam-dagar I see you closed the PR, are you still working on this issue?
@prateekj117 I think I was already in the queue :)
@shreyanshdwivedi @prateekj117 I am updating my PR. Please look for other issues. :smile: 
@iamareebjamal @shreyanshdwivedi I think case sensitive discount code is perfect , Case Insensitivity reduces the security factor , and finally its a promotional code which should be case sensitive . Should close this i suggest
@shreyanshdwivedi I would be working on this issue.
Why do we even need insensitivity in discount codes? @iamareebjamal @shreyanshdwivedi 
There are a lot of reasons. Mainly because we don't want someone to create codes like `summit19` and `suMMit19` and `SUMMit19` and `SUMMIT19` and have them behave differently
Code Sensitivity always provides an additional security factor on the codes . And as it is related to payments , Sensitivity should be given priority .
It provides annoyance and no security. Tomorrow someone will complain he/she got 50% off when it was written 75% off just because he didn't factor in case sensitivity. Or the discount code is not working altogether. Please back your claim with proof how it provides security?
@iamareebjamal May I work on this?
Go ahead

Resolving patch:
diff --git a/migrations/versions/ba651e8ce9a3_lowercase_discount_code.py b/migrations/versions/ba651e8ce9a3_lowercase_discount_code.py
new file mode 100644
--- /dev/null
+++ b/migrations/versions/ba651e8ce9a3_lowercase_discount_code.py
@@ -0,0 +1,25 @@
+"""lowercase discount code
+
+Revision ID: ba651e8ce9a3
+Revises: 4bdb4809f519
+Create Date: 2019-05-21 03:16:20.525011
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'ba651e8ce9a3'
+down_revision = '4bdb4809f519'
+
+
+def upgrade():
+    op.execute("alter table discount_codes alter column code type citext;",
+               execution_options=None)
+    op.create_unique_constraint('uq_event_discount_code', 'discount_codes', ['event_id', 'code'])
+
+
+def downgrade():
+    op.drop_constraint('uq_event_discount_code', 'discount_codes', type_='unique')
+    op.execute("alter table discount_codes alter column code type text;",
+               execution_options=None)


Test patch: