Skip to content

Commit

Permalink
get ether pad id and session while editing the article
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitbonik committed Sep 10, 2018
1 parent d6b727f commit f30945b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions BasicArticle/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.conf import settings
from Recommendation_API.views import get_Recommendations
import json
from etherpad.views import getHTML, getText, deletePad
from etherpad.views import getHTML, getText, deletePad, create_session_community, create_session_group, get_pad_id

def article_autosave(request,pk):
if request.user.is_authenticated:
Expand Down Expand Up @@ -234,6 +234,7 @@ def edit_article(request, pk):

try:
cmember = CommunityMembership.objects.get(user =request.user.id, community = article.community.pk)
sessionid = create_session_community(request, article.community.id)
try:
transition = Transitions.objects.get(from_state=article.article.state)
state1 = States.objects.get(name='draft')
Expand Down Expand Up @@ -265,6 +266,7 @@ def edit_article(request, pk):
cmember = CommunityMembership.objects.get(user=request.user.id, community = communitygroup.community.pk)
try:
gmember =GroupMembership.objects.get(user=request.user.id, group = article.group.pk)
sessionid = create_session_group(request, article.group.id)
except GroupMembership.DoesNotExist:
gmember = 'FALSE'
try:
Expand All @@ -285,7 +287,10 @@ def edit_article(request, pk):
# print ("Hello6")

raise Http404
return render(request, 'edit_article.html', {'article': article, 'cmember':cmember,'gmember':gmember,'message':message, 'belongs_to':belongs_to,'transition': transition, 'private':private,'uname':request.user,'url':settings.SERVERURL})
padid = get_pad_id(article.article.id)
response = render(request, 'edit_article.html', {'article': article, 'cmember':cmember,'gmember':gmember,'message':message, 'belongs_to':belongs_to,'transition': transition, 'private':private,'url':settings.SERVERURL, 'padid':padid})
response.set_cookie('sessionID', sessionid)
return response
else:
return redirect('login')

Expand Down
12 changes: 6 additions & 6 deletions templates/edit_article.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand All @@ -83,7 +83,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand Down Expand Up @@ -114,7 +114,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand Down Expand Up @@ -144,7 +144,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand All @@ -171,7 +171,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand All @@ -198,7 +198,7 @@
</div>
<div class="form-group">
<label for="body">Body</label>
<iframe src="{{url}}/p/{{article.article.pk}}?userName={{uname}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<iframe src="{{url}}/p/{{padid}}" style="height: 95%; width: 100%; min-height: 500px; display: block"></iframe>
<small id="bodyhelp" class="form-text text-muted">You can create your content in 4000 words.</small>
</div>
{% if article.article.image %}
Expand Down

0 comments on commit f30945b

Please sign in to comment.