Python users.models.User() Examples
The following are 11
code examples of users.models.User().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
users.models
, or try the search function
.
Example #1
Source File: aws.py From pycon with MIT License | 6 votes |
def send_notification( template_name: str, users: typing.List[User], substitutions: typing.Dict[str, typing.List[str]], ): client = _get_client() client.send_users_messages( ApplicationId=settings.PINPOINT_APPLICATION_ID, SendUsersMessageRequest={ "MessageConfiguration": { "EmailMessage": { "FromAddress": "noreply@pycon.it", "Substitutions": substitutions, } }, "TemplateConfiguration": {"EmailTemplate": {"Name": template_name}}, "Users": {str(user.id): {} for user in users}, }, ) # TODO: validate that it has been sent correctly
Example #2
Source File: aws.py From pycon with MIT License | 6 votes |
def send_comment_notification(comment): submission = comment.submission users: typing.Set[User] = set([submission.speaker]) # also send notification to all other commenters users = users.union(set([comment.author for comment in submission.comments.all()])) # don't notify current user users.discard(comment.author) if not users: return submission_url = urljoin( settings.FRONTEND_URL, f"/en/submission/{submission.hashid}" ) substitutions = { "submission_url": [submission_url], "submission": [submission.title], } send_notification("pycon-11-new-comment-on-submission", users, substitutions)
Example #3
Source File: exporter.py From pycon with MIT License | 6 votes |
def to_item(self): conferences_talks = { f"{code}_items_in_schedule": items for code, items in self.talks_by_conference.items() } return { "ChannelType": "EMAIL", "Address": self.email, "Id": self.id, "User": { "UserId": self.id, "UserAttributes": { "Name": [self.name], "FullName": [self.full_name], "is_staff": [str(self.is_staff)], "has_item_in_schedule": self.has_item_in_schedule, "has_cancelled_talks": self.has_cancelled_talks, "has_ticket": self.has_ticket, **conferences_talks, }, }, }
Example #4
Source File: mailjet.py From education-backend with MIT License | 6 votes |
def subscribe(self, user: User): response = self.client.contactslist_managecontact.create( id=settings.MAILJET_CONTACT_LIST_ID, data={ 'Action': 'addnoforce', 'Email': user.email, 'Properties': { 'name': str(user), 'firstname': user.first_name, 'lastname': user.last_name, }, }, ) if response.status_code != 201: raise AppMailjetWrongResponseException(f'Wrong response from mailjet: {response.status_code}. Content: {response.content}')
Example #5
Source File: exporter.py From pycon with MIT License | 5 votes |
def convert_user_to_endpoint(user: User) -> Endpoint: pretix_conferences = Conference.objects.exclude(pretix_event_id__exact="") submissions = Submission.objects.filter(speaker=user).values( "conference__code", "status" ) schedule_items = ScheduleItem.objects.filter( Q(submission__speaker=user) | Q(additional_speakers=user) ).values("conference__code", "title") talks_by_conference: typing.DefaultDict[str, typing.List[str]] = defaultdict(list) for item in schedule_items: talks_by_conference[item["conference__code"]].append(item["title"]) return Endpoint( id=str(user.id), name=user.name, full_name=user.full_name, email=user.email, is_staff=user.is_staff, has_sent_submission_to=list( set([submission["conference__code"] for submission in submissions]) ), has_item_in_schedule=list(talks_by_conference), has_ticket=[ conference.code for conference in pretix_conferences if user_has_admission_ticket(user.email, conference.pretix_event_id) ], has_cancelled_talks=list( set( [ submission["conference__code"] for submission in submissions if submission["status"] == Submission.STATUS.cancelled ] ) ), talks_by_conference=talks_by_conference, )
Example #6
Source File: folder.py From guacozy with MIT License | 5 votes |
def clean(self): super().clean() if self.group is None and self.user is None: raise ValidationError('Group or User has to be set') if self.group is not None and self.user is not None: raise ValidationError('Only one of Group or User can be set')
Example #7
Source File: views.py From diting with GNU General Public License v2.0 | 5 votes |
def get_user_count(): return User.objects.filter(role__in=('Admin', 'User')).count()
Example #8
Source File: user.py From education-backend with MIT License | 5 votes |
def __init__(self, user: User): self.user = user
Example #9
Source File: client.py From education-backend with MIT License | 5 votes |
def invite(self, webinar_id, user: User): user = ZoomusUser(user) return self.http.post( url=f'v2/webinars/{webinar_id}/registrants/', data=dict(user), expected_status_code=201, )
Example #10
Source File: mailchimp.py From education-backend with MIT License | 5 votes |
def subscribe(self, user: User): self._post( url=f'/lists/{settings.MAILCHIMP_CONTACT_LIST_ID}/members', payload={ 'email_address': user.email, 'status': 'subscribed', 'merge_fields': { 'FNAME': user.first_name, 'LNAME': user.last_name, }, }, )
Example #11
Source File: creator.py From education-backend with MIT License | 5 votes |
def __init__(self, user: User, item, **kwargs): self.item = item self.data = { 'user': user.pk, **kwargs, }