Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate code from app & api #8

Open
Bhupesh-V opened this issue Jul 26, 2019 · 1 comment · May be fixed by #73
Open

Remove duplicate code from app & api #8

Bhupesh-V opened this issue Jul 26, 2019 · 1 comment · May be fixed by #73
Labels
enhancement ⭐ New feature or request good first issue Good for newcomers help wanted 🙌 Extra attention is needed

Comments

@Bhupesh-V
Copy link
Owner

Currently the implementation of updating the db is almost the same in app & api

def post(self, request):
        linkCount = tutorial.objects.filter(link = request.POST['tlink']).count()
        if linkCount == 0:
            tags, title = generateTags(request.POST['tlink'])
            if 'other' in tags:
                return render(request, 'contribute.html', {'error': "Not a Tutorial Link, Try Again"})
            else:
                tutorialObject = tutorial.objects.create(
                    title = title, 
                    link = request.POST['tlink'], 
                    category = request.POST['tcategory']
                )
                for t in tags:
                    obj, created = tag.objects.get_or_create(name=t)

                tagObjList = tag.objects.filter(name__in = tags)
                tutorialObject.tags.set(tagObjList)

A possible solution is to shift this post method in serializers.py.

@Bhupesh-V Bhupesh-V added the enhancement ⭐ New feature or request label Jul 26, 2019
@Bhupesh-V Bhupesh-V changed the title Remove duplicate code from app & api Remove duplicate code from app & api Jul 27, 2019
@Bhupesh-V Bhupesh-V changed the title Remove duplicate code from app & api Remove duplicate code from app & api Jul 27, 2019
@Animesh-Ghosh Animesh-Ghosh added the help wanted 🙌 Extra attention is needed label Aug 17, 2019
@Animesh-Ghosh Animesh-Ghosh added the good first issue Good for newcomers label Aug 25, 2019
@siarheipuhach siarheipuhach linked a pull request Oct 23, 2019 that will close this issue
@siarheipuhach
Copy link

Please check my PR for that issue. #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ⭐ New feature or request good first issue Good for newcomers help wanted 🙌 Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants