temporary update
This commit is contained in:
@ -174,3 +174,24 @@ REST_FRAMEWORK = {
|
|||||||
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
|
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication', ),
|
'DEFAULT_AUTHENTICATION_CLASSES': ('knox.auth.TokenAuthentication', ),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||||
|
EMAIL_HOST = 'smtp.outlook.com'
|
||||||
|
EMAIL_PORT = 587
|
||||||
|
EMAIL_USE_TLS = True
|
||||||
|
EMAIL_HOST_USER = 'akira.miyata@gifuai.net'
|
||||||
|
EMAIL_HOST_PASSWORD = 'SachikoMiyata123'
|
||||||
|
DEFAULT_FROM_EMAIL = 'info@gifuai.net'
|
||||||
|
|
||||||
|
# settings.py
|
||||||
|
DEFAULT_CHARSET = 'utf-8'
|
||||||
|
|
||||||
|
#REST_FRAMEWORK = {
|
||||||
|
# 'DEFAULT_RENDERER_CLASSES': [
|
||||||
|
# 'rest_framework.renderers.JSONRenderer',
|
||||||
|
# ],
|
||||||
|
# 'JSON_UNICODE_ESCAPE': False,
|
||||||
|
#}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
dump_rog_data.sql
Normal file
1
dump_rog_data.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
pg_dump: error: connection to database "rogdb" failed: FATAL: Peer authentication failed for user "postgres"
|
||||||
73
rog/admin.py
73
rog/admin.py
@ -4,7 +4,7 @@ from django.shortcuts import render
|
|||||||
from leaflet.admin import LeafletGeoAdmin
|
from leaflet.admin import LeafletGeoAdmin
|
||||||
from leaflet.admin import LeafletGeoAdminMixin
|
from leaflet.admin import LeafletGeoAdminMixin
|
||||||
from leaflet_admin_list.admin import LeafletAdminListMixin
|
from leaflet_admin_list.admin import LeafletAdminListMixin
|
||||||
from .models import RogUser, Location, SystemSettings, JoinedEvent, Favorite, TravelList, TravelPoint, ShapeLayers, Event, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, CustomUser, GifuAreas, UserTracks, templocation, UserUpload, EventUser, GoalImages, CheckinImages
|
from .models import RogUser, Location, SystemSettings, JoinedEvent, Favorite, TravelList, TravelPoint, ShapeLayers, Event, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, CustomUser, GifuAreas, UserTracks, templocation, UserUpload, EventUser, GoalImages, CheckinImages, NewEvent, Team, Category, Entry, Member, TempUser
|
||||||
from django.contrib.auth.admin import UserAdmin
|
from django.contrib.auth.admin import UserAdmin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
@ -53,15 +53,18 @@ class UserAdminConfig(UserAdmin):
|
|||||||
print("-------Event code--------")
|
print("-------Event code--------")
|
||||||
for i in data:
|
for i in data:
|
||||||
_exist = CustomUser.objects.filter(email=i["zekken_number"]).delete()
|
_exist = CustomUser.objects.filter(email=i["zekken_number"]).delete()
|
||||||
|
other_fields.setDefaut('zekken_number',i['zekken_number'])
|
||||||
|
other_fields.setdefault('is_staff', True)
|
||||||
|
other_fields.setdefault('is_superuser', False)
|
||||||
|
other_fields.setdefault('is_active', True)
|
||||||
|
other_fields.setdefault('event_code', i['event_code'])
|
||||||
|
other_fields.setdefault('team_name', i['team_name'])
|
||||||
|
other_fields.setdefault('group', '大垣-初心者')
|
||||||
|
|
||||||
usr = CustomUser.objects.create_user(
|
usr = CustomUser.objects.create_user(
|
||||||
email=i["zekken_number"],
|
email=i["zekken_number"],
|
||||||
zekken_number=i['zekken_number'],
|
|
||||||
is_rogaining=True,
|
|
||||||
event_code=i['event_code'],
|
|
||||||
team_name=i['team_name'],
|
|
||||||
group='大垣-初心者',
|
|
||||||
password=i['password'],
|
password=i['password'],
|
||||||
is_staff= True
|
**other_fields
|
||||||
)
|
)
|
||||||
|
|
||||||
form = loadUserForm()
|
form = loadUserForm()
|
||||||
@ -193,7 +196,59 @@ class TempLocationAdmin(LeafletGeoAdmin):
|
|||||||
list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
||||||
actions = [tranfer_to_location,]
|
actions = [tranfer_to_location,]
|
||||||
|
|
||||||
|
@admin.register(NewEvent)
|
||||||
|
class NewEventAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['event_name', 'start_datetime', 'end_datetime']
|
||||||
|
search_fields = ['event_name']
|
||||||
|
|
||||||
|
@admin.register(Team)
|
||||||
|
class TeamAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['zekken_number', 'team_name', 'owner']
|
||||||
|
search_fields = ['zekken_number', 'team_name', 'owner__email']
|
||||||
|
|
||||||
|
@admin.register(Category)
|
||||||
|
class CategoryAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['category_name', 'category_number', 'duration', 'num_of_member', 'family', 'female']
|
||||||
|
list_filter = ['family', 'female']
|
||||||
|
search_fields = ['category_name']
|
||||||
|
|
||||||
|
@admin.register(Entry)
|
||||||
|
class EntryAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['team', 'event', 'category', 'date']
|
||||||
|
list_filter = ['event', 'category']
|
||||||
|
search_fields = ['team__team_name', 'event__event_name']
|
||||||
|
|
||||||
|
@admin.register(Member)
|
||||||
|
class MemberAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['team', 'user']
|
||||||
|
search_fields = ['team__team_name', 'user__email']
|
||||||
|
|
||||||
|
@admin.register(TempUser)
|
||||||
|
class TempUserAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ['email', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group', 'created_at', 'expires_at']
|
||||||
|
list_filter = ['is_rogaining', 'group']
|
||||||
|
search_fields = ['email', 'zekken_number', 'team_name']
|
||||||
|
|
||||||
|
|
||||||
|
# CustomUserAdmin の修正(既存のものを更新)
|
||||||
|
class CustomUserAdmin(UserAdmin):
|
||||||
|
list_display = ('email', 'is_staff', 'is_active', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group', 'firstname', 'lastname')
|
||||||
|
list_filter = ('is_staff', 'is_active', 'is_rogaining', 'group')
|
||||||
|
fieldsets = (
|
||||||
|
(None, {'fields': ('email', 'password')}),
|
||||||
|
('Personal info', {'fields': ('firstname', 'lastname', 'date_of_birth', 'female')}),
|
||||||
|
('Permissions', {'fields': ('is_staff', 'is_active', 'is_rogaining','user_permissions')}),
|
||||||
|
('Rogaining info', {'fields': ('zekken_number', 'event_code', 'team_name', 'group')}),
|
||||||
|
)
|
||||||
|
add_fieldsets = (
|
||||||
|
(None, {
|
||||||
|
'classes': ('wide',),
|
||||||
|
#'fields': ('email', 'password1', 'password2', 'is_staff', 'is_active', 'is_rogaining')}
|
||||||
|
'fields': ('email', 'password1', 'password2', 'lastname','firstname', 'date_of_birth', 'female','is_staff', 'is_active', 'is_rogaining')}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
search_fields = ('email', 'firstname', 'lastname', 'zekken_number', 'team_name')
|
||||||
|
ordering = ('email',)
|
||||||
|
|
||||||
admin.site.register(Useractions)
|
admin.site.register(Useractions)
|
||||||
admin.site.register(RogUser, admin.ModelAdmin)
|
admin.site.register(RogUser, admin.ModelAdmin)
|
||||||
@ -220,3 +275,7 @@ admin.site.register(CustomUser, UserAdminConfig)
|
|||||||
admin.site.register(templocation, TempLocationAdmin)
|
admin.site.register(templocation, TempLocationAdmin)
|
||||||
admin.site.register(GoalImages, admin.ModelAdmin)
|
admin.site.register(GoalImages, admin.ModelAdmin)
|
||||||
admin.site.register(CheckinImages, admin.ModelAdmin)
|
admin.site.register(CheckinImages, admin.ModelAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
rog/management/commands/cleanup_temp_users.py
Normal file
16
rog/management/commands/cleanup_temp_users.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.utils import timezone
|
||||||
|
from rog.models import TempUser # アプリ名 'rog' を適切に変更してください
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Deletes expired temporary user records'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
expired_users = TempUser.objects.filter(expires_at__lt=timezone.now())
|
||||||
|
count = expired_users.count()
|
||||||
|
expired_users.delete()
|
||||||
|
self.stdout.write(self.style.SUCCESS(f'Successfully deleted {count} expired temporary user records'))
|
||||||
|
|
||||||
|
|
||||||
|
# cron job の設定
|
||||||
|
# 0 3 * * * /path/to/your/python /path/to/your/manage.py cleanup_temp_users
|
||||||
113
rog/migrations/0042_auto_20240722_1603.py
Normal file
113
rog/migrations/0042_auto_20240722_1603.py
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# Generated by Django 3.2.9 on 2024-07-22 07:03
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('rog', '0041_auto_20230526_1724'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Category',
|
||||||
|
fields=[
|
||||||
|
('category_name', models.CharField(max_length=255, primary_key=True, serialize=False)),
|
||||||
|
('category_number', models.IntegerField(unique=True)),
|
||||||
|
('duration', models.DurationField(default=datetime.timedelta(seconds=18000))),
|
||||||
|
('num_of_member', models.IntegerField(default=1)),
|
||||||
|
('family', models.BooleanField(default=False)),
|
||||||
|
('female', models.BooleanField(default=False)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('category_name', 'category_number')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='NewEvent',
|
||||||
|
fields=[
|
||||||
|
('event_name', models.CharField(max_length=255, primary_key=True, serialize=False)),
|
||||||
|
('start_datetime', models.DateTimeField(default=django.utils.timezone.now)),
|
||||||
|
('end_datetime', models.DateTimeField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TempUser',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('email', models.EmailField(max_length=254, unique=True)),
|
||||||
|
('password', models.CharField(max_length=128)),
|
||||||
|
('is_rogaining', models.BooleanField(default=False)),
|
||||||
|
('zekken_number', models.CharField(blank=True, max_length=255, null=True)),
|
||||||
|
('event_code', models.CharField(blank=True, max_length=255, null=True)),
|
||||||
|
('team_name', models.CharField(blank=True, max_length=255, null=True)),
|
||||||
|
('group', models.CharField(max_length=255)),
|
||||||
|
('firstname', models.CharField(blank=True, max_length=255, null=True)),
|
||||||
|
('lastname', models.CharField(blank=True, max_length=255, null=True)),
|
||||||
|
('date_of_birth', models.DateField(blank=True, null=True)),
|
||||||
|
('female', models.BooleanField(default=False)),
|
||||||
|
('verification_code', models.UUIDField(default=uuid.uuid4, editable=False)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('expires_at', models.DateTimeField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='date_of_birth',
|
||||||
|
field=models.DateField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='female',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='firstname',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customuser',
|
||||||
|
name='lastname',
|
||||||
|
field=models.CharField(blank=True, max_length=255, null=True),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Team',
|
||||||
|
fields=[
|
||||||
|
('zekken_number', models.CharField(max_length=255, primary_key=True, serialize=False)),
|
||||||
|
('team_name', models.CharField(max_length=255)),
|
||||||
|
('password', models.CharField(max_length=128)),
|
||||||
|
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Member',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rog.team')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('team', 'user')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Entry',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('date', models.DateTimeField()),
|
||||||
|
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rog.category')),
|
||||||
|
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rog.newevent')),
|
||||||
|
('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rog.team')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('team', 'event', 'date')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -69,13 +69,13 @@ def remove_bom_inplace(path):
|
|||||||
|
|
||||||
class CustomUserManager(BaseUserManager):
|
class CustomUserManager(BaseUserManager):
|
||||||
|
|
||||||
def create_user(self, email, password, group, event_code, team_name, **other_fields):
|
def create_user(self, email, password=None, **other_fields):
|
||||||
if not email:
|
if not email:
|
||||||
raise ValueError(_("You must provide an email address"))
|
raise ValueError(_("You must provide an email address"))
|
||||||
|
email = self.normalize_email(email)
|
||||||
user = self.model(email=email, group=group, event_code=event_code, team_name=team_name, zekken_number=email, is_rogaining=True, **other_fields)
|
user = self.model(email=email, **other_fields)
|
||||||
user.set_password(password)
|
user.set_password(password)
|
||||||
user.save()
|
user.save(using=self._db)
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class CustomUserManager(BaseUserManager):
|
|||||||
if other_fields.get('is_superuser') is not True:
|
if other_fields.get('is_superuser') is not True:
|
||||||
raise ValueError(_('Superuser must have is_superuser set to True'))
|
raise ValueError(_('Superuser must have is_superuser set to True'))
|
||||||
|
|
||||||
return self.create_user(email, password, group, event_code, team_name, **other_fields)
|
return self.create_user(email, password, **other_fields)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ class TempUser(models.Model):
|
|||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
return timezone.now() <= self.expires_at
|
return timezone.now() <= self.expires_at
|
||||||
|
|
||||||
class Event(models.Model):
|
class NewEvent(models.Model):
|
||||||
event_name = models.CharField(max_length=255, primary_key=True)
|
event_name = models.CharField(max_length=255, primary_key=True)
|
||||||
start_datetime = models.DateTimeField(default=timezone.now)
|
start_datetime = models.DateTimeField(default=timezone.now)
|
||||||
end_datetime = models.DateTimeField()
|
end_datetime = models.DateTimeField()
|
||||||
@ -311,7 +311,7 @@ class Category(models.Model):
|
|||||||
|
|
||||||
class Entry(models.Model):
|
class Entry(models.Model):
|
||||||
team = models.ForeignKey(Team, on_delete=models.CASCADE)
|
team = models.ForeignKey(Team, on_delete=models.CASCADE)
|
||||||
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
event = models.ForeignKey(NewEvent, on_delete=models.CASCADE)
|
||||||
category = models.ForeignKey(Category, on_delete=models.CASCADE)
|
category = models.ForeignKey(Category, on_delete=models.CASCADE)
|
||||||
date = models.DateTimeField()
|
date = models.DateTimeField()
|
||||||
|
|
||||||
@ -1002,7 +1002,10 @@ def updatePolygonTable(mdl, fields):
|
|||||||
|
|
||||||
def createUser(fields):
|
def createUser(fields):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
user = CustomUser.objects.create_user(email=fields[0], event_code=fields[1], team_name=fields[2], group=fields[3], password=fields[4])
|
other_fields.setdefault('event_code',fields[1])
|
||||||
|
other_fields.setdefault('team_name',fields[1])
|
||||||
|
other_fields.setdefault('group',fields[1])
|
||||||
|
user = CustomUser.objects.create_user(email=fields[0], password=fields[4], **other_fields)
|
||||||
user.is_superuser = False
|
user.is_superuser = False
|
||||||
user.is_staff = False
|
user.is_staff = False
|
||||||
user.save()
|
user.save()
|
||||||
|
|||||||
6
rog/permissions.py
Normal file
6
rog/permissions.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
class IsMemberOrTeamOwner(permissions.BasePermission):
|
||||||
|
def has_object_permission(self, request, view, obj):
|
||||||
|
# obj は Member インスタンス
|
||||||
|
return request.user == obj.user or request.user == obj.team.owner
|
||||||
@ -1,7 +1,7 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework_gis.serializers import GeoFeatureModelSerializer
|
from rest_framework_gis.serializers import GeoFeatureModelSerializer
|
||||||
from sqlalchemy.sql.functions import mode
|
from sqlalchemy.sql.functions import mode
|
||||||
from .models import Location, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, GifuAreas, RogUser, UserTracks, GoalImages, CheckinImages,CustomUser
|
from .models import Location, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, GifuAreas, RogUser, UserTracks, GoalImages, CheckinImages,CustomUser,NewEvent, Team, Category, Entry, Member, TempUser
|
||||||
from drf_extra_fields.fields import Base64ImageField
|
from drf_extra_fields.fields import Base64ImageField
|
||||||
|
|
||||||
#from django.contrib.auth.models import User
|
#from django.contrib.auth.models import User
|
||||||
@ -193,3 +193,50 @@ class RegistrationSerializer(serializers.ModelSerializer):
|
|||||||
user.set_password(password)
|
user.set_password(password)
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
class NewEventSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = NewEvent
|
||||||
|
fields = ['event_name', 'start_datetime', 'end_datetime']
|
||||||
|
|
||||||
|
class TeamSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Team
|
||||||
|
fields = ['zekken_number', 'team_name', 'password', 'owner']
|
||||||
|
|
||||||
|
class CategorySerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Category
|
||||||
|
fields = ['category_name', 'category_number', 'duration', 'num_of_member', 'family', 'female']
|
||||||
|
|
||||||
|
class EntrySerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Entry
|
||||||
|
fields = ['team', 'event', 'category', 'date']
|
||||||
|
|
||||||
|
class MemberSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Member
|
||||||
|
fields = ['team', 'user']
|
||||||
|
|
||||||
|
class TempUserSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = TempUser
|
||||||
|
fields = ['email', 'password', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group', 'firstname', 'lastname', 'date_of_birth', 'female', 'verification_code', 'created_at', 'expires_at']
|
||||||
|
|
||||||
|
class CustomUserSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = CustomUser
|
||||||
|
fields = ['email', 'is_staff', 'is_active', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group', 'firstname', 'lastname', 'date_of_birth', 'female']
|
||||||
|
|
||||||
|
class UserSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = CustomUser
|
||||||
|
fields = ['email', 'firstname', 'lastname', 'date_of_birth', 'female', 'is_rogaining', 'zekken_number', 'event_code', 'team_name', 'group']
|
||||||
|
|
||||||
|
class MemberWithUserSerializer(serializers.ModelSerializer):
|
||||||
|
user = UserSerializer(read_only=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Member
|
||||||
|
fields = ['user', 'team']
|
||||||
|
|||||||
27
rog/urls.py
27
rog/urls.py
@ -1,7 +1,7 @@
|
|||||||
from sys import prefix
|
from sys import prefix
|
||||||
from rest_framework import urlpatterns
|
from rest_framework import urlpatterns
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, LocationsInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet, ExtentForLocations, DeleteAccount, PrivacyView, RegistrationView
|
from .views import LocationViewSet, Location_lineViewSet, Location_polygonViewSet, Jpn_Main_PerfViewSet, LocationsInPerf, ExtentForSubPerf, SubPerfInMainPerf, ExtentForMainPerf, LocationsInSubPerf, CatView, RegistrationAPI, LoginAPI, UserAPI, UserActionViewset, UserMakeActionViewset, UserDestinations, UpdateOrder, LocationInBound, DeleteDestination, CustomAreaLocations, GetAllGifuAreas, CustomAreaNames, userDetials, UserTracksViewSet, CatByCity, ChangePasswordView, GoalImageViewSet, CheckinImageViewSet, ExtentForLocations, DeleteAccount, PrivacyView, RegistrationView, TeamViewSet,MemberViewSet,EntryViewSet,RegisterView, VerifyEmailView, NewEventListView,CategoryListView, MemberUserDetailView, TeamMembersWithUserView
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from knox import views as knox_views
|
from knox import views as knox_views
|
||||||
|
|
||||||
@ -18,6 +18,24 @@ router.register(prefix='track', viewset=UserTracksViewSet, basename='track')
|
|||||||
router.register(prefix='goalimage', viewset=GoalImageViewSet, basename='goalimage')
|
router.register(prefix='goalimage', viewset=GoalImageViewSet, basename='goalimage')
|
||||||
router.register(prefix='checkinimage', viewset=CheckinImageViewSet, basename='checkinimage')
|
router.register(prefix='checkinimage', viewset=CheckinImageViewSet, basename='checkinimage')
|
||||||
|
|
||||||
|
#Akira 追加
|
||||||
|
# /api/teams/ - チームの一覧取得と作成
|
||||||
|
# /api/teams/<pk>/ - 特定のチームの取得、更新、削除
|
||||||
|
# /api/members/ - メンバーの一覧取得と作成
|
||||||
|
# /api/members/<pk>/ - 特定のメンバーの取得、更新、削除
|
||||||
|
# /api/entries/ - エントリーの一覧取得と作成
|
||||||
|
# /api/entries/<pk>/ - 特定のエントリーの取得、更新、削除
|
||||||
|
#
|
||||||
|
router.register(r'teams', TeamViewSet)
|
||||||
|
router.register(r'members', MemberViewSet)
|
||||||
|
router.register(r'entries', EntryViewSet)
|
||||||
|
|
||||||
|
# Akira 追加
|
||||||
|
# GET /api/members/<member_id>/user/: 特定のメンバーのユーザー情報を取得
|
||||||
|
# GET /api/teams/<team_id>/members-with-user/: 特定のチームの全メンバーとそのユーザー情報を取得
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
|
|
||||||
@ -49,4 +67,11 @@ urlpatterns += [
|
|||||||
path('privacy/', PrivacyView, name='privacy-view'),
|
path('privacy/', PrivacyView, name='privacy-view'),
|
||||||
path('register', RegistrationView.as_view(), name='register'),
|
path('register', RegistrationView.as_view(), name='register'),
|
||||||
# path('goal-image/', GoalImageViewSet.as_view(), name='goal-image')
|
# path('goal-image/', GoalImageViewSet.as_view(), name='goal-image')
|
||||||
|
path('register/', RegisterView.as_view(), name='register'),
|
||||||
|
path('verify-email/<uuid:verification_code>/', VerifyEmailView.as_view(), name='verify-email'),
|
||||||
|
path('categories/', CategoryListView.as_view(), name='category-list'),
|
||||||
|
path('new-events/', NewEventListView.as_view(), name='new-event-list'),
|
||||||
|
path('members/<int:pk>/user/', MemberUserDetailView.as_view(), name='member-user-detail'),
|
||||||
|
path('teams/<int:team_id>/members-with-user/', TeamMembersWithUserView.as_view(), name='team-members-with-user'),
|
||||||
|
|
||||||
]
|
]
|
||||||
190
rog/views.py
190
rog/views.py
@ -1,8 +1,8 @@
|
|||||||
from curses.ascii import NUL
|
from curses.ascii import NUL
|
||||||
from django.core.serializers import serialize
|
from django.core.serializers import serialize
|
||||||
from .models import GoalImages, Location, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, GifuAreas, RogUser, CustomUser, UserTracks, GoalImages, CheckinImages
|
from .models import GoalImages, Location, Location_line, Location_polygon, JpnAdminMainPerf, Useractions, GifuAreas, RogUser, CustomUser, UserTracks, GoalImages, CheckinImages, NewEvent, Team, Category, Entry, Member, TempUser
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from .serializers import LocationSerializer, Location_lineSerializer, Location_polygonSerializer, JPN_main_perfSerializer, LocationCatSerializer, CreateUserSerializer, UserSerializer, LoginUserSerializer, UseractionsSerializer, UserDestinationSerializer, GifuAreaSerializer, LocationEventNameSerializer, RogUserSerializer, UserTracksSerializer, ChangePasswordSerializer, GolaImageSerializer, CheckinImageSerializer, RegistrationSerializer
|
from .serializers import LocationSerializer, Location_lineSerializer, Location_polygonSerializer, JPN_main_perfSerializer, LocationCatSerializer, CreateUserSerializer, UserSerializer, LoginUserSerializer, UseractionsSerializer, UserDestinationSerializer, GifuAreaSerializer, LocationEventNameSerializer, RogUserSerializer, UserTracksSerializer, ChangePasswordSerializer, GolaImageSerializer, CheckinImageSerializer, RegistrationSerializer, MemberWithUserSerializer
|
||||||
from knox.models import AuthToken
|
from knox.models import AuthToken
|
||||||
|
|
||||||
from rest_framework import viewsets, generics, status
|
from rest_framework import viewsets, generics, status
|
||||||
@ -14,7 +14,7 @@ from django.http import JsonResponse
|
|||||||
from rest_framework.permissions import IsAuthenticated
|
from rest_framework.permissions import IsAuthenticated
|
||||||
from django.contrib.gis.db.models import Extent, Union
|
from django.contrib.gis.db.models import Extent, Union
|
||||||
|
|
||||||
from .serializers import TestSerialiser
|
from .serializers import TestSerialiser,NewEventSerializer, TeamSerializer, CategorySerializer, EntrySerializer, MemberSerializer, TempUserSerializer, CustomUserSerializer
|
||||||
from .models import TestModel
|
from .models import TestModel
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
@ -29,8 +29,10 @@ from rest_framework.parsers import JSONParser, MultiPartParser
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
import uuid
|
import uuid
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from .permissions import IsMemberOrTeamOwner
|
||||||
|
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.utils.encoding import force_str
|
||||||
|
|
||||||
class LocationViewSet(viewsets.ModelViewSet):
|
class LocationViewSet(viewsets.ModelViewSet):
|
||||||
queryset=Location.objects.all()
|
queryset=Location.objects.all()
|
||||||
@ -557,3 +559,183 @@ class RegistrationView(APIView):
|
|||||||
serializer.save()
|
serializer.save()
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
# Akira
|
||||||
|
|
||||||
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
|
class NewEventViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = NewEvent.objects.all()
|
||||||
|
serializer_class = NewEventSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
|
class NewEventListView(generics.ListAPIView):
|
||||||
|
queryset = NewEvent.objects.all()
|
||||||
|
serializer_class = NewEventSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
class TeamViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Team.objects.all()
|
||||||
|
serializer_class = TeamSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
serializer.save(owner=self.request.user)
|
||||||
|
|
||||||
|
class CategoryViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Category.objects.all()
|
||||||
|
serializer_class = CategorySerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
@method_decorator(csrf_exempt, name='dispatch')
|
||||||
|
class CategoryListView(generics.ListAPIView):
|
||||||
|
queryset = Category.objects.all()
|
||||||
|
serializer_class = CategorySerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
'''
|
||||||
|
def get(self, request):
|
||||||
|
categories = Category.objects.all()
|
||||||
|
data = []
|
||||||
|
for category in categories:
|
||||||
|
category_name = force_str(category.category_name)
|
||||||
|
data.append({
|
||||||
|
'category_name': category_name,
|
||||||
|
# その他のフィールド
|
||||||
|
})
|
||||||
|
return Response(data)
|
||||||
|
'''
|
||||||
|
|
||||||
|
class EntryViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Entry.objects.all()
|
||||||
|
serializer_class = EntrySerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
team = Team.objects.get(owner=self.request.user)
|
||||||
|
serializer.save(team=team)
|
||||||
|
|
||||||
|
|
||||||
|
class MemberViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Member.objects.all()
|
||||||
|
serializer_class = MemberSerializer
|
||||||
|
permission_classes = [permissions.IsAuthenticated]
|
||||||
|
|
||||||
|
|
||||||
|
class TempUserViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = TempUser.objects.all()
|
||||||
|
serializer_class = TempUserSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
# CustomUserViewSetの修正
|
||||||
|
class CustomUserViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = CustomUser.objects.all()
|
||||||
|
serializer_class = CustomUserSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
user = self.request.user
|
||||||
|
if user.is_staff:
|
||||||
|
return CustomUser.objects.all()
|
||||||
|
return CustomUser.objects.filter(id=user.id)
|
||||||
|
|
||||||
|
# 追加の機能として、チームメンバーを取得するビュー
|
||||||
|
from rest_framework.decorators import action
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
class TeamMembersView(generics.ListAPIView):
|
||||||
|
serializer_class = MemberSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
team_id = self.kwargs['team_id']
|
||||||
|
return Member.objects.filter(team_id=team_id)
|
||||||
|
|
||||||
|
# ユーザーのエントリーを取得するビュー
|
||||||
|
class UserEntriesView(generics.ListAPIView):
|
||||||
|
serializer_class = EntrySerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
user = self.request.user
|
||||||
|
return Entry.objects.filter(team__owner=user)
|
||||||
|
|
||||||
|
# イベントのカテゴリーを取得するビュー
|
||||||
|
class EventCategoriesView(generics.ListAPIView):
|
||||||
|
serializer_class = CategorySerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
event_id = self.kwargs['event_id']
|
||||||
|
return Category.objects.filter(entry__event_id=event_id).distinct()
|
||||||
|
|
||||||
|
class RegisterView(APIView):
|
||||||
|
def post(self, request):
|
||||||
|
serializer = TempUserSerializer(data=request.data)
|
||||||
|
if serializer.is_valid():
|
||||||
|
temp_user = serializer.save()
|
||||||
|
verification_code = uuid.uuid4()
|
||||||
|
temp_user.verification_code = verification_code
|
||||||
|
temp_user.save()
|
||||||
|
|
||||||
|
verification_url = request.build_absolute_uri(
|
||||||
|
reverse('verify-email', kwargs={'verification_code': verification_code})
|
||||||
|
)
|
||||||
|
send_mail(
|
||||||
|
'Verify your email',
|
||||||
|
f'Click the link to verify your email: {verification_url}',
|
||||||
|
settings.DEFAULT_FROM_EMAIL,
|
||||||
|
[temp_user.email],
|
||||||
|
fail_silently=False,
|
||||||
|
)
|
||||||
|
return Response({'message': 'Verification email sent'}, status=status.HTTP_201_CREATED)
|
||||||
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
class VerifyEmailView(APIView):
|
||||||
|
def get(self, request, verification_code):
|
||||||
|
try:
|
||||||
|
temp_user = TempUser.objects.get(verification_code=verification_code)
|
||||||
|
if temp_user.is_valid():
|
||||||
|
user_data = {
|
||||||
|
'email': temp_user.email,
|
||||||
|
'is_rogaining': temp_user.is_rogaining,
|
||||||
|
'zekken_number': temp_user.zekken_number,
|
||||||
|
'event_code': temp_user.event_code,
|
||||||
|
'team_name': temp_user.team_name,
|
||||||
|
'group': temp_user.group,
|
||||||
|
'firstname': temp_user.firstname,
|
||||||
|
'lastname': temp_user.lastname,
|
||||||
|
'date_of_birth': temp_user.date_of_birth,
|
||||||
|
'female': temp_user.female,
|
||||||
|
}
|
||||||
|
# CustomUserを作成
|
||||||
|
user = CustomUser.objects.create_user(
|
||||||
|
email=user_data['email'],
|
||||||
|
password=temp_user.password,
|
||||||
|
**{k: v for k, v in user_data.items() if k != 'email'}
|
||||||
|
)
|
||||||
|
temp_user.delete()
|
||||||
|
return Response({'message': 'Email verified and user created'}, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return Response({'message': 'Verification link expired'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
except TempUser.DoesNotExist:
|
||||||
|
return Response({'message': 'Invalid verification code'}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
|
class MemberUserDetailView(generics.RetrieveAPIView):
|
||||||
|
serializer_class = MemberWithUserSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return Member.objects.select_related('user', 'team')
|
||||||
|
|
||||||
|
class TeamMembersWithUserView(generics.ListAPIView):
|
||||||
|
serializer_class = MemberWithUserSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
team_id = self.kwargs['team_id']
|
||||||
|
return Member.objects.filter(team_id=team_id).select_related('user', 'team')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
247
rogaining_env_py310/bin/Activate.ps1
Normal file
247
rogaining_env_py310/bin/Activate.ps1
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Activate a Python virtual environment for the current PowerShell session.
|
||||||
|
|
||||||
|
.Description
|
||||||
|
Pushes the python executable for a virtual environment to the front of the
|
||||||
|
$Env:PATH environment variable and sets the prompt to signify that you are
|
||||||
|
in a Python virtual environment. Makes use of the command line switches as
|
||||||
|
well as the `pyvenv.cfg` file values present in the virtual environment.
|
||||||
|
|
||||||
|
.Parameter VenvDir
|
||||||
|
Path to the directory that contains the virtual environment to activate. The
|
||||||
|
default value for this is the parent of the directory that the Activate.ps1
|
||||||
|
script is located within.
|
||||||
|
|
||||||
|
.Parameter Prompt
|
||||||
|
The prompt prefix to display when this virtual environment is activated. By
|
||||||
|
default, this prompt is the name of the virtual environment folder (VenvDir)
|
||||||
|
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Activate.ps1
|
||||||
|
Activates the Python virtual environment that contains the Activate.ps1 script.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Activate.ps1 -Verbose
|
||||||
|
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||||
|
and shows extra information about the activation as it executes.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
||||||
|
Activates the Python virtual environment located in the specified location.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Activate.ps1 -Prompt "MyPython"
|
||||||
|
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||||
|
and prefixes the current prompt with the specified string (surrounded in
|
||||||
|
parentheses) while the virtual environment is active.
|
||||||
|
|
||||||
|
.Notes
|
||||||
|
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
||||||
|
execution policy for the user. You can do this by issuing the following PowerShell
|
||||||
|
command:
|
||||||
|
|
||||||
|
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
|
|
||||||
|
For more information on Execution Policies:
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=135170
|
||||||
|
|
||||||
|
#>
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[String]
|
||||||
|
$VenvDir,
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[String]
|
||||||
|
$Prompt
|
||||||
|
)
|
||||||
|
|
||||||
|
<# Function declarations --------------------------------------------------- #>
|
||||||
|
|
||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Remove all shell session elements added by the Activate script, including the
|
||||||
|
addition of the virtual environment's Python executable from the beginning of
|
||||||
|
the PATH variable.
|
||||||
|
|
||||||
|
.Parameter NonDestructive
|
||||||
|
If present, do not remove this function from the global namespace for the
|
||||||
|
session.
|
||||||
|
|
||||||
|
#>
|
||||||
|
function global:deactivate ([switch]$NonDestructive) {
|
||||||
|
# Revert to original values
|
||||||
|
|
||||||
|
# The prior prompt:
|
||||||
|
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
||||||
|
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
||||||
|
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
||||||
|
}
|
||||||
|
|
||||||
|
# The prior PYTHONHOME:
|
||||||
|
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
||||||
|
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
||||||
|
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
||||||
|
}
|
||||||
|
|
||||||
|
# The prior PATH:
|
||||||
|
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
||||||
|
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
||||||
|
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
||||||
|
}
|
||||||
|
|
||||||
|
# Just remove the VIRTUAL_ENV altogether:
|
||||||
|
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
||||||
|
Remove-Item -Path env:VIRTUAL_ENV
|
||||||
|
}
|
||||||
|
|
||||||
|
# Just remove VIRTUAL_ENV_PROMPT altogether.
|
||||||
|
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
|
||||||
|
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
|
||||||
|
}
|
||||||
|
|
||||||
|
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
||||||
|
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
||||||
|
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Leave deactivate function in the global namespace if requested:
|
||||||
|
if (-not $NonDestructive) {
|
||||||
|
Remove-Item -Path function:deactivate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.Description
|
||||||
|
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
||||||
|
given folder, and returns them in a map.
|
||||||
|
|
||||||
|
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
||||||
|
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
||||||
|
then it is considered a `key = value` line. The left hand string is the key,
|
||||||
|
the right hand is the value.
|
||||||
|
|
||||||
|
If the value starts with a `'` or a `"` then the first and last character is
|
||||||
|
stripped from the value before being captured.
|
||||||
|
|
||||||
|
.Parameter ConfigDir
|
||||||
|
Path to the directory that contains the `pyvenv.cfg` file.
|
||||||
|
#>
|
||||||
|
function Get-PyVenvConfig(
|
||||||
|
[String]
|
||||||
|
$ConfigDir
|
||||||
|
) {
|
||||||
|
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
||||||
|
|
||||||
|
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
||||||
|
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
||||||
|
|
||||||
|
# An empty map will be returned if no config file is found.
|
||||||
|
$pyvenvConfig = @{ }
|
||||||
|
|
||||||
|
if ($pyvenvConfigPath) {
|
||||||
|
|
||||||
|
Write-Verbose "File exists, parse `key = value` lines"
|
||||||
|
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
||||||
|
|
||||||
|
$pyvenvConfigContent | ForEach-Object {
|
||||||
|
$keyval = $PSItem -split "\s*=\s*", 2
|
||||||
|
if ($keyval[0] -and $keyval[1]) {
|
||||||
|
$val = $keyval[1]
|
||||||
|
|
||||||
|
# Remove extraneous quotations around a string value.
|
||||||
|
if ("'""".Contains($val.Substring(0, 1))) {
|
||||||
|
$val = $val.Substring(1, $val.Length - 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
$pyvenvConfig[$keyval[0]] = $val
|
||||||
|
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pyvenvConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<# Begin Activate script --------------------------------------------------- #>
|
||||||
|
|
||||||
|
# Determine the containing directory of this script
|
||||||
|
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||||
|
$VenvExecDir = Get-Item -Path $VenvExecPath
|
||||||
|
|
||||||
|
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
||||||
|
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
||||||
|
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
||||||
|
|
||||||
|
# Set values required in priority: CmdLine, ConfigFile, Default
|
||||||
|
# First, get the location of the virtual environment, it might not be
|
||||||
|
# VenvExecDir if specified on the command line.
|
||||||
|
if ($VenvDir) {
|
||||||
|
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
||||||
|
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
||||||
|
Write-Verbose "VenvDir=$VenvDir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Next, read the `pyvenv.cfg` file to determine any required value such
|
||||||
|
# as `prompt`.
|
||||||
|
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
||||||
|
|
||||||
|
# Next, set the prompt from the command line, or the config file, or
|
||||||
|
# just use the name of the virtual environment folder.
|
||||||
|
if ($Prompt) {
|
||||||
|
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
||||||
|
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
||||||
|
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
||||||
|
$Prompt = $pyvenvCfg['prompt'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
|
||||||
|
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
||||||
|
$Prompt = Split-Path -Path $venvDir -Leaf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Prompt = '$Prompt'"
|
||||||
|
Write-Verbose "VenvDir='$VenvDir'"
|
||||||
|
|
||||||
|
# Deactivate any currently active virtual environment, but leave the
|
||||||
|
# deactivate function in place.
|
||||||
|
deactivate -nondestructive
|
||||||
|
|
||||||
|
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
||||||
|
# that there is an activated venv.
|
||||||
|
$env:VIRTUAL_ENV = $VenvDir
|
||||||
|
|
||||||
|
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
||||||
|
|
||||||
|
Write-Verbose "Setting prompt to '$Prompt'"
|
||||||
|
|
||||||
|
# Set the prompt to include the env name
|
||||||
|
# Make sure _OLD_VIRTUAL_PROMPT is global
|
||||||
|
function global:_OLD_VIRTUAL_PROMPT { "" }
|
||||||
|
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
||||||
|
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
||||||
|
|
||||||
|
function global:prompt {
|
||||||
|
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
||||||
|
_OLD_VIRTUAL_PROMPT
|
||||||
|
}
|
||||||
|
$env:VIRTUAL_ENV_PROMPT = $Prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clear PYTHONHOME
|
||||||
|
if (Test-Path -Path Env:PYTHONHOME) {
|
||||||
|
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
||||||
|
Remove-Item -Path Env:PYTHONHOME
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add the venv to the PATH
|
||||||
|
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
||||||
|
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
||||||
69
rogaining_env_py310/bin/activate
Normal file
69
rogaining_env_py310/bin/activate
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# This file must be used with "source bin/activate" *from bash*
|
||||||
|
# you cannot run it directly
|
||||||
|
|
||||||
|
deactivate () {
|
||||||
|
# reset old environment variables
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||||
|
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||||
|
export PATH
|
||||||
|
unset _OLD_VIRTUAL_PATH
|
||||||
|
fi
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||||
|
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||||
|
export PYTHONHOME
|
||||||
|
unset _OLD_VIRTUAL_PYTHONHOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This should detect bash and zsh, which have a hash command that must
|
||||||
|
# be called to get it to forget past commands. Without forgetting
|
||||||
|
# past commands the $PATH changes we made may not be respected
|
||||||
|
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||||
|
hash -r 2> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||||
|
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||||
|
export PS1
|
||||||
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset VIRTUAL_ENV
|
||||||
|
unset VIRTUAL_ENV_PROMPT
|
||||||
|
if [ ! "${1:-}" = "nondestructive" ] ; then
|
||||||
|
# Self destruct!
|
||||||
|
unset -f deactivate
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# unset irrelevant variables
|
||||||
|
deactivate nondestructive
|
||||||
|
|
||||||
|
VIRTUAL_ENV="/home/sumasen/rogaining_srv/rogaining_env_py310"
|
||||||
|
export VIRTUAL_ENV
|
||||||
|
|
||||||
|
_OLD_VIRTUAL_PATH="$PATH"
|
||||||
|
PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
# unset PYTHONHOME if set
|
||||||
|
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||||
|
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||||
|
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||||
|
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||||
|
unset PYTHONHOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||||
|
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||||
|
PS1="(rogaining_env_py310) ${PS1:-}"
|
||||||
|
export PS1
|
||||||
|
VIRTUAL_ENV_PROMPT="(rogaining_env_py310) "
|
||||||
|
export VIRTUAL_ENV_PROMPT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This should detect bash and zsh, which have a hash command that must
|
||||||
|
# be called to get it to forget past commands. Without forgetting
|
||||||
|
# past commands the $PATH changes we made may not be respected
|
||||||
|
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||||
|
hash -r 2> /dev/null
|
||||||
|
fi
|
||||||
26
rogaining_env_py310/bin/activate.csh
Normal file
26
rogaining_env_py310/bin/activate.csh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# This file must be used with "source bin/activate.csh" *from csh*.
|
||||||
|
# You cannot run it directly.
|
||||||
|
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
||||||
|
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
||||||
|
|
||||||
|
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
|
||||||
|
|
||||||
|
# Unset irrelevant variables.
|
||||||
|
deactivate nondestructive
|
||||||
|
|
||||||
|
setenv VIRTUAL_ENV "/home/sumasen/rogaining_srv/rogaining_env_py310"
|
||||||
|
|
||||||
|
set _OLD_VIRTUAL_PATH="$PATH"
|
||||||
|
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
|
||||||
|
set _OLD_VIRTUAL_PROMPT="$prompt"
|
||||||
|
|
||||||
|
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
||||||
|
set prompt = "(rogaining_env_py310) $prompt"
|
||||||
|
setenv VIRTUAL_ENV_PROMPT "(rogaining_env_py310) "
|
||||||
|
endif
|
||||||
|
|
||||||
|
alias pydoc python -m pydoc
|
||||||
|
|
||||||
|
rehash
|
||||||
69
rogaining_env_py310/bin/activate.fish
Normal file
69
rogaining_env_py310/bin/activate.fish
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
|
||||||
|
# (https://fishshell.com/); you cannot run it directly.
|
||||||
|
|
||||||
|
function deactivate -d "Exit virtual environment and return to normal shell environment"
|
||||||
|
# reset old environment variables
|
||||||
|
if test -n "$_OLD_VIRTUAL_PATH"
|
||||||
|
set -gx PATH $_OLD_VIRTUAL_PATH
|
||||||
|
set -e _OLD_VIRTUAL_PATH
|
||||||
|
end
|
||||||
|
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
||||||
|
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
||||||
|
set -e _OLD_VIRTUAL_PYTHONHOME
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
||||||
|
set -e _OLD_FISH_PROMPT_OVERRIDE
|
||||||
|
# prevents error when using nested fish instances (Issue #93858)
|
||||||
|
if functions -q _old_fish_prompt
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _old_fish_prompt fish_prompt
|
||||||
|
functions -e _old_fish_prompt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set -e VIRTUAL_ENV
|
||||||
|
set -e VIRTUAL_ENV_PROMPT
|
||||||
|
if test "$argv[1]" != "nondestructive"
|
||||||
|
# Self-destruct!
|
||||||
|
functions -e deactivate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Unset irrelevant variables.
|
||||||
|
deactivate nondestructive
|
||||||
|
|
||||||
|
set -gx VIRTUAL_ENV "/home/sumasen/rogaining_srv/rogaining_env_py310"
|
||||||
|
|
||||||
|
set -gx _OLD_VIRTUAL_PATH $PATH
|
||||||
|
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
||||||
|
|
||||||
|
# Unset PYTHONHOME if set.
|
||||||
|
if set -q PYTHONHOME
|
||||||
|
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
||||||
|
set -e PYTHONHOME
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
||||||
|
# fish uses a function instead of an env var to generate the prompt.
|
||||||
|
|
||||||
|
# Save the current fish_prompt function as the function _old_fish_prompt.
|
||||||
|
functions -c fish_prompt _old_fish_prompt
|
||||||
|
|
||||||
|
# With the original prompt function renamed, we can override with our own.
|
||||||
|
function fish_prompt
|
||||||
|
# Save the return status of the last command.
|
||||||
|
set -l old_status $status
|
||||||
|
|
||||||
|
# Output the venv prompt; color taken from the blue of the Python logo.
|
||||||
|
printf "%s%s%s" (set_color 4B8BBE) "(rogaining_env_py310) " (set_color normal)
|
||||||
|
|
||||||
|
# Restore the return status of the previous command.
|
||||||
|
echo "exit $old_status" | .
|
||||||
|
# Output the original/"old" prompt.
|
||||||
|
_old_fish_prompt
|
||||||
|
end
|
||||||
|
|
||||||
|
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
||||||
|
set -gx VIRTUAL_ENV_PROMPT "(rogaining_env_py310) "
|
||||||
|
end
|
||||||
8
rogaining_env_py310/bin/f2py
Executable file
8
rogaining_env_py310/bin/f2py
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from numpy.f2py.f2py2e import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
8
rogaining_env_py310/bin/numpy-config
Executable file
8
rogaining_env_py310/bin/numpy-config
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from numpy._configtool import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
8
rogaining_env_py310/bin/pip
Executable file
8
rogaining_env_py310/bin/pip
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pip._internal.cli.main import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
8
rogaining_env_py310/bin/pip3
Executable file
8
rogaining_env_py310/bin/pip3
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pip._internal.cli.main import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
8
rogaining_env_py310/bin/pip3.10
Executable file
8
rogaining_env_py310/bin/pip3.10
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pip._internal.cli.main import main
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
1
rogaining_env_py310/bin/python
Symbolic link
1
rogaining_env_py310/bin/python
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
python3.10
|
||||||
1
rogaining_env_py310/bin/python3
Symbolic link
1
rogaining_env_py310/bin/python3
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
python3.10
|
||||||
1
rogaining_env_py310/bin/python3.10
Symbolic link
1
rogaining_env_py310/bin/python3.10
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/usr/bin/python3.10
|
||||||
8
rogaining_env_py310/bin/rio
Executable file
8
rogaining_env_py310/bin/rio
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/home/sumasen/rogaining_srv/rogaining_env_py310/bin/python3.10
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from rasterio.rio.main import main_group
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||||
|
sys.exit(main_group())
|
||||||
1
rogaining_env_py310/lib64
Symbolic link
1
rogaining_env_py310/lib64
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
lib
|
||||||
3
rogaining_env_py310/pyvenv.cfg
Normal file
3
rogaining_env_py310/pyvenv.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
home = /usr/bin
|
||||||
|
include-system-site-packages = false
|
||||||
|
version = 3.10.14
|
||||||
44463
takayama_logs.txt
Normal file
44463
takayama_logs.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user