3030from ast import literal_eval
3131import json
3232import requests
33- # Create your views here.
33+ from etherpad . views import create_community_ether , create_article_ether_community , create_session_community
3434
3535def display_communities (request ):
3636 if request .method == 'POST' :
@@ -133,14 +133,19 @@ def community_article_create(request):
133133 if status == '1' :
134134 article = create_article (request )
135135 CommunityArticles .objects .create (article = article , user = request .user , community = community )
136+
137+ #create the ether id for artcile blonging to this community
138+ padid = create_article_ether_community (cid , article )
139+
136140 # return community_article_create_body(request, article, community)
137141 data = {
138142 'article_id' :article .id ,
139143 'community_or_group_id' :community .pk ,
140144 'user_id' :request .user .id ,
141145 'username' :request .user .username ,
142146 'url' :settings .SERVERURL ,
143- 'articleof' :'community'
147+ 'articleof' :'community' ,
148+ 'padid' :padid
144149 }
145150 return JsonResponse (data )
146151 # return redirect('article_edit', article.pk)
@@ -166,7 +171,11 @@ def community_article_create(request):
166171 data = {}
167172 return JsonResponse (data )
168173 else :
169- return render (request , 'new_article.html' , {'community' :community , 'status' :1 })
174+ #create the session for this article in ether pad
175+ sid = create_session_community (request , cid )
176+ response = render (request , 'new_article.html' , {'community' :community , 'status' :1 })
177+ response .set_cookie ('sessionID' , sid )
178+ return response
170179 else :
171180 return redirect ('home' )
172181 else :
@@ -255,6 +264,9 @@ def handle_community_creation_requests(request):
255264
256265 )
257266
267+ #create the ether id for community
268+ create_community_ether (communitycreation )
269+
258270 create_wiki_for_community (communitycreation )
259271 communityadmin = Roles .objects .get (name = 'community_admin' )
260272 communitymembership = CommunityMembership .objects .create (
@@ -433,6 +445,9 @@ def create_community(request):
433445 remove_or_add_user_feed (usr ,community ,'community_created' )
434446 notify_remove_or_add_user (request .user , usr ,community ,'community_created' )
435447
448+ #create the ether id for community
449+ create_community_ether (community )
450+
436451 create_wiki_for_community (community )
437452
438453 return redirect ('community_view' , community .pk )
0 commit comments