Skip to content

随意填写#62

Open
DimLight1998 wants to merge 1 commit intoTHUCampus:masterfrom
DimLight1998:dev-alice
Open

随意填写#62
DimLight1998 wants to merge 1 commit intoTHUCampus:masterfrom
DimLight1998:dev-alice

Conversation

@DimLight1998
Copy link
Copy Markdown

No description provided.

Comment thread adminpage/views.py
# Create your views here.

# 登录
class adminLogin(APIView):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name should use PascalCase.

Comment thread adminpage/views.py
def get(self):
# if self.request.user.is_authenticated():
activity_List = []
activites = Activity.objects.all()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use built-in objects filtering functions of django?

Comment thread adminpage/views.py
ticket_List = Ticket.objects.filter(activity=activity)
bookedTickets = 0
usedTickets = 0
for t in ticket_List:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use built-in counting functions of django?

Comment thread userpage/views.py
raise ValidateError('Not found')
activity = activity_list[0]
if(activity.status != Activity.STATUS_PUBLISHED):
raise ValidateError("活动已截止")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a ValidateError?

Comment thread adminpage/views.py
for index in image.chunks():
f.write(index)
f.close()
return SITE_DOMAIN + '/img/activityImage/' + image.name
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.path.join.

Comment thread adminpage/views.py

allActs = Activity.objects.all()
for a in allActs:
if a not in acts:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use built-in functions.

Comment thread wechat/handlers.py
unique_id = uuid.uuid5(uuid.NAMESPACE_DNS,self.user.student_id + activity.name + str(currentTime))
Ticket.objects.create(student_id = self.user.student_id, unique_id = unique_id,
activity = activity, status = Ticket.STATUS_VALID)
activity.remain_tickets -= 1
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lock.

Comment thread wechat/wrapper.py
def reply_news(self, articles):
if len(articles) > 10:
self.logger.warn('Reply with %d articles, keep only 10', len(articles))
if len(articles) > 8:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move 8 to a variable.

Copy link
Copy Markdown
Author

@DimLight1998 DimLight1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • No authenticating for admin.
  • Use unified naming convention.
  • Add to_json and create_from_json method to models to reduce meaningless code when get information of create object.
  • Don't comment code when committing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant