def UserProfile(Request, User_id): User = Users.objects.filter(id=User_id, Activate=1, Deleted=0) if not User.exists(): return StatusPages.NotFoundPage(Request, 'User') Result = Hashing.GetAllFromHashing([{'Type': 'Users', 'Data': User[0].Email, 'Key': 'Email'}]) if Result['Result'] == -1: return StatusPages.ErrorPage(Request, 'User') Articles = Posts.objects.filter(User_Email=Hashing.Hash_Articles(Result['Data']['Email']), Deleted=0)[:5] return UserProfile_Render(Request, User[0], Articles)
def EditArticle(Request, Article_id): if not GF.SESSION(Request): return StatusPages.UnAuthurithedUserPage(Request, 'Edit Article') Post = Posts.objects.filter(User_Email=Hashing.Hash_Articles( Request.session["Email"]), id=Article_id, Deleted=0) if not Post.exists(): return StatusPages.NotFoundPage(Request, 'Edit Article') if Request.method == 'POST' and URL.REFERER_is_Set(Request): Form = MakeArticleForm(Request.POST) if Form.isValid() and URL.GetREFERER( Request) == init.EditArticle + str(Post[0].id): return EditArticle_POSTResponse(Form, Article_id) Result = Hashing.GetAllFromHashing([{ 'Type': 'Articles', 'Data': Post[0].Article, 'Key': 'Post' }, { 'Type': 'Articles', 'Data': Post[0].ArticleTitle, 'Key': 'Title' }, { 'Type': 'Articles', 'Data': Post[0].Tags, 'Key': 'Tags' }]) if Result['Result'] == -1: return StatusPages.ErrorPage(Request, 'Edit Article') if 'Edited' in Request.GET: Result = { 'id': Article_id, 'GetButtonValue': 'Edit This Article', 'GetResult': 'Edited', 'GetPage': '' } return Render.MakeOrEditSuccess_Render(Request, 'Edit Article', Result) return Render.EditArticle_Render( Request, 'Edited' if 'Edited' in Request.GET else '', Result['Data']['Title'], Result['Data']['Post'], Result['Data']['Tags'])