Kodecard - create coding e-cards


This is a project that allows users to create their own Kodecard featuring your skills, and links to your github, devto, twitter, linkedin, and website. They can then create an iframe to use on their websites.


https://firebasestorage.googleapis.com/v0/b/alonzoaustin-8314b.appspot.com/o/7_4_21%2Fkodecard%2Fatumnkodecard.png?alt=media&token=bb9afd19-c6dc-463d-b258-21d0fa1996f4https://firebasestorage.googleapis.com/v0/b/alonzoaustin-8314b.appspot.com/o/7_4_21%2Fkodecard%2Fkodecardcopy.gif?alt=media&token=a7fd4290-c59b-4076-8fa6-de00958b710ehttps://firebasestorage.googleapis.com/v0/b/alonzoaustin-8314b.appspot.com/o/7_4_21%2Fkodecard%2Fkodecardedit.gif?alt=media&token=99c265b8-fe8b-46e2-acba-2ac99917d31b

Authentication

Instead of using Django's native authentication system, I decided to keep things simple by using what I know-Auth0. To implement Auth0, I followed the quickstart guide that Auth0 made for those using Django. (I'm not going to mention how I implemented this in this devlog because you can read it from their official guide.

Testing

This was the first time I used unit testing. I created sample data and ran tests to validate user's submitted data. To do this, I had to create three functions, each starting with the word test to ensure that django could read the tests. In the first test, I created empty data, in the second, I created too much, while in the third, I created data where everything is alright. To run the test, I ran the following command in my terminal: python manage.py test auth0login (the app name is auth0login because I bundled everything in the app I created following the auth0 guide) the test looked like this:


from django.test import TestCase
from auth0login.models import card

# Create your tests here.

class cardTest(TestCase):

    def test_nothing_not_accepted(self):
        no_user = card(full_name="", theme="", summary="", pic="", github="", devto="", twitter="", linkedin="", website="", user_id="")
        self.assertIs(no_user.full_name_is_not_empty_or_above_ahundred_chars(), False)
        self.assertIs(no_user.theme_is_not_empty_or_above_eight_chars(), False)
        self.assertIs(no_user.summary_is_not_empty_or_above_athousand_chars(), False)
        self.assertIs(no_user.pic_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.github_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.devto_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.twitter_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.linkedin_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.website_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(no_user.user_id_is_not_empty_or_above_ahundred_chars(), False)
        self.assertIs(no_user.theme_is_available(), False)

    def test_overboard_not_accepted(self):
        overboard =         card(
            full_name="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 
            theme="aaaaaaaaa", 
            summary="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 
            linkedin="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 
            website="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 
            user_id="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        )
        self.assertIs(overboard.full_name_is_not_empty_or_above_ahundred_chars(), False)
        self.assertIs(overboard.theme_is_not_empty_or_above_eight_chars(), False)
        self.assertIs(overboard.summary_is_not_empty_or_above_athousand_chars(), False)
        self.assertIs(overboard.pic_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.github_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.devto_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.twitter_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.linkedin_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.website_is_not_empty_or_above_twohundred_chars(), False)
        self.assertIs(overboard.user_id_is_not_empty_or_above_ahundred_chars(), False)
        self.assertIs(overboard.theme_is_available(), False)

    def test_normal_not_accepted(self):
        normal = card(
            full_name="Alonzo Austin", 
            theme="atumn   ", 
            summary="I am a full stack web Developer who utilizes Nextjs using ReactJS Hooks and EXPRESSJS With EJS as a template engine. The three main Databases I use are Fauna, Firestore and MongoDB. I'm always learning new methods and technologies through creating projects and taking what I've learned to improve my existing projects.", 
            pic="https://alonzoaustin.com/mypic.png", 
            github="https://github.com/glowtoad123", 
            devto="https://dev.to/glowtoad123", 
            twitter="https://twitter.com/glowtoad123", 
            linkedin="https://www.linkedin.com/in/alonzo-austin/", 
            website="https://alonzoaustin.com/", 
            user_id="auth0|602c51c435703a0069e55115"
        )
        self.assertIs(normal.full_name_is_not_empty_or_above_ahundred_chars(), True)
        self.assertIs(normal.theme_is_not_empty_or_above_eight_chars(), True)
        self.assertIs(normal.summary_is_not_empty_or_above_athousand_chars(), True)
        self.assertIs(normal.pic_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.github_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.devto_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.twitter_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.linkedin_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.website_is_not_empty_or_above_twohundred_chars(), True)
        self.assertIs(normal.user_id_is_not_empty_or_above_ahundred_chars(), True)
        self.assertIs(normal.theme_is_available(), True)
        
            

Views

In order to Make sure that the Users can receive all of their data, I had to make sure that when a query is made, every property would be returned to the user. In order to do this, I had to add a __str__(self): function in the models.py file so that something would be returned. In that function, I added the following so that everything could be returned instead of just one property:


    def __str__(self):
        return json.dumps({
            "full_name": self.full_name,
            "theme": self.theme,
            "summary": self.summary,
            "pic": self.pic,
            "github": self.github,
            "devto": self.devto,
            "twitter": self.twitter,
            "linkedin": self.linkedin,
            "website": self.website,
            "user_id": self.user_id,
        }, indent=4)

Once a user is signedin, I made sure that the user's credentials could be accessed by the views. In the dashboard view, the view would check to see if that user has a card. If not, the user would be directed to the edit page.