1
+ import secrets
2
+ import string
3
+ from datetime import datetime , timedelta
4
+
1
5
import graphene
2
6
import graphql_jwt
3
- from datetime import date , datetime , timedelta
4
-
7
+ from django .contrib .auth import get_user_model
5
8
from django .contrib .auth .hashers import check_password
6
- from django .utils import timezone
7
- from graphql_jwt .decorators import permission_required , login_required
8
9
from django .contrib .auth .models import User
10
+ from django .core .mail import send_mail
9
11
from django .db .models import Avg
10
- from django .contrib .auth import get_user_model
12
+ from django .template .loader import render_to_string
13
+ from django .utils import timezone
14
+ from django .utils .html import strip_tags
11
15
from graphene_django import DjangoObjectType
16
+ from graphql_jwt .decorators import login_required
12
17
13
- import attendance .schema
14
18
import activity .schema
15
- from dairy .schema import Query as dairyQuery
16
- from registration .schema import Mutation as registrationMutation , Query as registrationQuery
17
- import tasks .schema
18
- import status .schema
19
+ import attendance .schema
19
20
import password .schema
20
- from .api .APIException import APIException
21
+ import status .schema
22
+ import tasks .schema
23
+ import gallery .schema
24
+ from attendance .api .log import userAttendanceObj
25
+ from attendance .models import Log
21
26
from dairy .schema import Mutation as eventMutation
22
-
23
- from members .schema import Query as MembersQuery , Mutation as membersMutation
24
- from members .api .profile import ProfileObj
27
+ from dairy .schema import Query as dairyQuery
28
+ from framework import settings
25
29
from members .api .group import GroupObj
30
+ from members .api .profile import ProfileObj
26
31
from members .models import Profile , Group
27
-
28
- from attendance .models import Log
29
- from attendance .api .log import userAttendanceObj
30
-
31
- from .api .user import UserBasicObj
32
+ from members .schema import Query as MembersQuery , Mutation as membersMutation
33
+ from registration .schema import Mutation as registrationMutation , Query as registrationQuery
34
+ from .api .APIException import APIException
32
35
from .api .mutation import Mutation as PlatformMutation
33
-
34
- import secrets ,string
35
-
36
- from framework import settings
37
- from django .core .mail import send_mail
38
- from django .template .loader import render_to_string
39
- from django .utils .html import strip_tags
36
+ from .api .user import UserBasicObj
40
37
41
38
from_email = settings .EMAIL_HOST_USER
42
39
@@ -210,6 +207,7 @@ def mutate(self, info, username=None, firstName=None, lastName=None, email=None,
210
207
profile .save ()
211
208
return userResponseObj (id = user .id )
212
209
210
+
213
211
class ResetPassword (graphene .Mutation ):
214
212
class Arguments :
215
213
email = graphene .String (required = True )
@@ -223,16 +221,18 @@ def mutate(self, info, email):
223
221
user .set_password (newPassword )
224
222
user .save ()
225
223
context = {
226
- "password" : newPassword ,
227
- "username" : user .username
224
+ "password" : newPassword ,
225
+ "username" : user .username
228
226
}
229
227
message = render_to_string ('email/password_reset_email.html' , context )
230
- send_mail ('Reset Password | amFOSS CMS' , strip_tags (message ) , from_email , [email ], fail_silently = False , html_message = message )
228
+ send_mail ('Reset Password | amFOSS CMS' , strip_tags (message ), from_email , [email ], fail_silently = False ,
229
+ html_message = message )
231
230
return userStatusObj (status = True )
232
231
else :
233
232
raise APIException ('Email is not registered' ,
234
233
code = 'WRONG_EMAIL' )
235
234
235
+
236
236
class Query (
237
237
dairyQuery ,
238
238
MembersQuery ,
@@ -242,6 +242,7 @@ class Query(
242
242
tasks .schema .Query ,
243
243
activity .schema .Query ,
244
244
status .schema .Query ,
245
+ gallery .schema .Query ,
245
246
graphene .ObjectType
246
247
):
247
248
user = graphene .Field (UserObj , username = graphene .String (required = True ))
@@ -294,7 +295,8 @@ def resolve_inActiveUsers(self, info, **kwargs):
294
295
code = 'ONLY_SUPERUSER_HAS_ACCESS' )
295
296
296
297
297
- class Mutation (membersMutation , attendance .schema .Mutation , registrationMutation , eventMutation , PlatformMutation , graphene .ObjectType ):
298
+ class Mutation (membersMutation , attendance .schema .Mutation , registrationMutation , eventMutation , PlatformMutation ,
299
+ graphene .ObjectType ):
298
300
token_auth = graphql_jwt .ObtainJSONWebToken .Field ()
299
301
verify_token = graphql_jwt .Verify .Field ()
300
302
refresh_token = graphql_jwt .Refresh .Field ()
0 commit comments