Repository: CiviWiki/OpenCiviWiki

Issue:
Can't Publish New Thread
I attempted to make a new thread on Civiwiki.org. I was able to create the content, but when I hit publish it throws a server error. 

![image](https://user-images.githubusercontent.com/30572202/57983784-ba53aa00-7a23-11e9-8e32-a036612b47b3.png)





Discussion:
@mdwest is there any error in your browser console (F12)? What is the server error? Please provide the texts.
*Note: It now says it is published when I hit publish, but I don't see it on the feed page yet. I'll update soon. 

-mw

This should now be fixed by Tomasz' PR, just merged into develop. Pleasr test again on civiwiki-dev.
@mdwest this may now be resolved by the recent deployment. Please verify.
Currently traveling, but I'll check asap.

-mw

On Sat, May 18, 2019, 1:52 AM Brylie Christopher Oxley <
notifications@github.com> wrote:

> @mdwest <https://github.com/mdwest> this may now be resolved by the
> recent deployment. Please verify.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/CiviWiki/OpenCiviWiki/issues/477?email_source=notifications&email_token=AHJH5KTO47EBZ5C56AFFQALPV67TDA5CNFSM4HMSQCQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVWKS3I#issuecomment-493660525>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AHJH5KRK2N2XCPZTMLLVZE3PV67TDANCNFSM4HMSQCQQ>
> .
>

@mdwest verified by email that this issue still affects the `dev` branch, despite us reverting to the previous version.

@mdwest please set up a Sentry account for CiviWiki, so we can track server errors.
OK, it looks like Sentry has been configured for CiviWiki, but I am unable to access the Sentry logs. @mdwest can you invite me to the CiviWiki Sentry team?
@brylie 
I have tested this issue. When I click on publish button, it occurs an server error, as following. 
Some icons can not be displaied either, e.g., keyboard_arrow_down.

![image](https://user-images.githubusercontent.com/23006864/57981870-fa407e80-7a6f-11e9-81a3-3cef8a570c02.png)


OK, thanks for reproducing @SunflowerPKU. Would you like to try and diagnose this error on the server-side? E.g. see if you can get a console log or other output for the specific server error.
I finally got the project to run locally again, and got the following error in the server console when trying to publish a  thread:

```
Editing thread
civiwiki-db | ERROR:  null value in column "title" violates not-null constraint
civiwiki-db | DETAIL:  Failing row contains (1, null, null, 2019-05-22 20:12:18.333649+00, 2019-05-22 20:19:40.302053+00, 1, null, 0, 0, 2, , null, null, t).
civiwiki-db | STATEMENT:  UPDATE "api_thread" SET "author_id" = 1, "category_id" = NULL, "title" = NULL, "summary" = NULL, "image" = '', "level" = NULL, "state" = NULL, "created" = '2019-05-22T20:12:18.333649+00:00'::timestamptz, "last_modified" = '2019-05-22T20:19:40.302053+00:00'::timestamptz, "is_draft" = true, "num_views" = 2, "num_civis" = 0, "num_solutions" = 0 WHERE "api_thread"."id" = 1
civiwiki-backend | null value in column "title" violates not-null constraint
civiwiki-backend | DETAIL:  Failing row contains (1, null, null, 2019-05-22 20:12:18.333649+00, 2019-05-22 20:19:40.302053+00, 1, null, 0, 0, 2, , null, null, t).
```
I just tested the latest code and the publish button now appears to work (no server error message and a message says it is now public and refreshing) but the thread does not actually publish. 

The thread remains in drafts for the publishing account and is not visible on the feed of other accounts. 



@TomaszKolek are you working on this issue?
My understanding is tomasz has only proposed researching the issue and we
have not yet agreed on a contract.

-mw

On Fri, May 24, 2019, 4:05 AM Brylie Christopher Oxley <
notifications@github.com> wrote:

> @TomaszKolek <https://github.com/TomaszKolek> are you working on this
> issue?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/CiviWiki/OpenCiviWiki/issues/477?email_source=notifications&email_token=AHJH5KWQN6T4GTTJYPBY3JDPW6OVPA5CNFSM4HMSQCQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWEPEVQ#issuecomment-495514198>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AHJH5KSEYDTUXYUISJODNXTPW6OVPANCNFSM4HMSQCQQ>
> .
>


Resolving patch:
diff --git a/project/api/write.py b/project/api/write.py
--- a/project/api/write.py
+++ b/project/api/write.py
@@ -263,7 +263,8 @@ def editThread(request):
     if not thread_id:
         return HttpResponseBadRequest(reason="Invalid Thread Reference")
 
-    if not is_draft:
+    # for some reason this is not cast to boolean in the request
+    if is_draft == "false":
         Thread.objects.filter(id=thread_id).update(is_draft=False)
 
         return JsonResponse({'data': "Success"})


Test patch: