This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| def checkName(name): | |
| values = { "new_username" : name } | |
| r = requests.post("https://login.skype.com/json/validator", values) | |
| return "not available" in r.json()[u'data'][u'markup'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if not article.is_visible or not article.is_moderate: | |
| is_author = article.author == request.user | |
| if request.user.is_admin or request.user.is_staff or is_author: | |
| pass | |
| else: | |
| raise PermissionDenied | |
| #EDITED |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if form.is_valid(): | |
| original_name, extension = os.path.splitext(form.cleaned_data['file'].name) # расширение файла из формы | |
| path = os.path.join(settings.MEDIA_ROOT, DIR) | |
| file_name = image_name_resolver(path) # принимает путь, отдаёт верное имя(без расширения) для файла | |
| complete_name = file_name + extension | |
| ... | |
| def image_name_resolver(path): | |
| ''' |