-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tags for people (SEA-1445 und SEA-1437). Show avatars.
- Loading branch information
1 parent
4763ebe
commit 2bc6d1b
Showing
22 changed files
with
585 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import click | ||
from pyramid.paster import bootstrap | ||
from pyramid.paster import get_appsettings | ||
|
||
from privatim.models import User | ||
from privatim.models.profile_pic import get_or_create_default_profile_pic | ||
from privatim.orm import get_engine, Base | ||
|
||
|
||
@click.command() | ||
@click.argument('config_uri') | ||
def main(config_uri: str) -> None: | ||
|
||
env = bootstrap(config_uri) | ||
settings = get_appsettings(config_uri) | ||
engine = get_engine(settings) | ||
Base.metadata.create_all(engine) | ||
|
||
with env['request'].tm: | ||
dbsession = env['request'].dbsession | ||
|
||
# Update existing users and generate profile pics | ||
default_pic = get_or_create_default_profile_pic(dbsession) | ||
users = dbsession.query(User).all() | ||
for user in users: | ||
# Generate tags if not present | ||
if not user.tags: | ||
user.tags = ( | ||
user.first_name[:1] + user.last_name[:1] | ||
).upper() or user.email[:2].upper() | ||
|
||
if ( | ||
user.profile_pic is None or | ||
user.profile_pic.content == default_pic.content | ||
or user.profile_pic_id is None | ||
): | ||
user.generate_profile_picture(dbsession) | ||
|
||
dbsession.flush() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Binary file not shown.
Binary file not shown.
Oops, something went wrong.